jpa Specification使用
来源:互联网 发布:php程序员的工作常态 编辑:程序博客网 时间:2024/06/02 04:37
spring jpa Specification 使用
本文只是做个笔记,备忘
public Page<Message> list(BootPage bootPage,MessageQuery messageQuery){ Pageable pageable = new PageRequest(bootPage.getOffset() / bootPage.getLimit(), bootPage.getLimit(),bootPage.getOrder()); Specification<Message> spec1 = (root, query, cb) -> { Path<Long> tPath = root.get("target"); /*Target is ALL*/ cb.equal(tPath, Message.Target.ALL); return null; }; Specification<Message> spec2 = (root, query, cb) -> { Path<Long> tPath = root.get("target"); Path<String> vPath = root.get("value"); /*or , Target is SCHOOL and value like ou */ cb.equal(tPath, Message.Target.SCHOOL); cb.like(vPath, "%"+messageQuery.getOu().trim()+"%"); return null; }; Specification<Message> spec3 = (root, query, cb) -> { Path<Long> tPath = root.get("target"); Path<String> vPath = root.get("value"); /*Target is PERSONAL and value like uid*/ cb.equal(tPath,Message.Target.PERSONAL); cb.like(vPath,"%"+messageQuery.getUid()+"%"); return null; }; Specification spec = Specifications.where(spec1).or(spec2).or(spec3); return repository.findAll(spec,pageable); }
阅读全文
0 0
- jpa Specification使用
- spring data jpa Specification的使用
- Spring data JPA使用Specification实现动态查询例子
- JPA Specification 的写法
- jpa specification条件查询
- 3 Spring JPA Specification 查询
- Spring Data JPA Specification查询
- JPA Specification常用查询+排序
- spring data jpa specification的封装
- spring-data-jpa Specification 拼接复杂查询
- spring data jpa Specification 多对一检索
- jpa多条件查询重写Specification的toPredicate方法
- Hibernate JPA Specification重写toPredicate多条件查询
- JPA查询之Specification以及HQL、SQL查询
- jpa多条件查询重写Specification的toPredicate方法
- JPA使用
- jpa使用
- jpa使用
- 第二章 第六节:默认约束DEFAULT
- IDEA main方法自动补全
- hls之m3u8、ts流格式详解
- Android中View创建的流程
- BZOJ3687 简单题 解题报告 【递推】【bitset】
- jpa Specification使用
- 单例模式与多线程(二)
- 全局变量重复定义
- Python机器学习笔记——概述
- unity中使用www加载本地资源
- 普元 EOS Platform 7.6 webservice图元添加自定义Header
- 块存储、文件存储、对象存储
- 高并发下生成订单唯一流水号的方法
- mysql数据库日期以字符串形式存储