springboot ,spring-data,jpa
总结:今天主要讲解一下jpa 的动态sql,用过hibernate 都知道有个qbc(动态sql),hql,
jpa呢 加 jql,和标准查询
动态sql ,主要重写 findAll 代码如下:
解析sql 如下
select user0_.id as id1_0_, user0_.create_time as create_t2_0_, user0_.name as name3_0_ from user user0_ where (user0_.id in (1 , 2)) and cast(user0_.create_time as char)>? and user0_.create_time<? and user0_.id<=2 and (user0_.name like ? or user0_.id<=2) order by user0_.name desc limit ?, ?
基本 动态 sql 两种写法,上面就是第一种,动态构建 Predicate
另一种解法是上面提到的 Example Matchers,动态构造ExampleMatcher即可 https://docs.spring.io/spring-data/jpa/docs/current/reference/html/
参考链接
http://www.voidcn.com/article/p-uzaenzpv-bss.html
https://github.com/wenhao/jpa-spec
https://www.cnblogs.com/xzmxddx/p/10975733.html
https://www.jianshu.com/p/8046233c0178
https://blog.csdn.net/liuyunyihao/article/details/81194007
https://zhuanlan.zhihu.com/p/24778422
https://wiselyman.iteye.com/blog/2378154
https://blog.csdn.net/cn_hhaip/article/details/89527666
https://blog.csdn.net/weixin_34379433/article/details/87537687
官方文档
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/
https://blog.csdn.net/moshowgame/article/details/80058270 多表关联
https://www.cnblogs.com/alterem/p/11295358.html
其他文章
https://www.cnblogs.com/zimug/p/11790285.html