jap 复合查询
来源:互联网 发布:c语言初始化顺序表 编辑:程序博客网 时间:2024/05/16 14:30
@Override
public Page<Document> searchSendDocument(Long sendUserId, Long sendGroupId,String title,
String content, Date stDate, Date spDate, int pageNum,
int numPerPage) {
final String titl1F = title;
final String contentF = content;
final Date stDateF = stDate;
final Date spDateF = spDate;
final Long sendUserIdF = sendUserId;
final Long sendGroupIdF = sendGroupId;
Sort sort = new Sort(Direction.DESC, "id");
Pageable pageRequest = new PageRequest(pageNum - 1, numPerPage, sort);
Specification<Document> spec = new Specification<Document>() {
@Override
public Predicate toPredicate(Root<Document> root,
CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicate = new ArrayList<>();
if (titl1F != null && titl1F.trim().length() > 0) {
predicate.add(cb.like(root.get("title").as(String.class),
"%" + titl1F.trim() + "%"));
}
if (contentF != null && contentF.trim().length() > 0) {
predicate.add(cb.like(root.get("message").as(String.class),
"%" + contentF.trim() + "%"));
}
if (sendUserIdF != SearchEnum.SEARCH_ALL.getId()) {
predicate.add(cb.equal(root.get("userId").as(Long.class),
sendUserIdF));
}
predicate.add(cb.equal(root.get("isState").as(Integer.class),
DocumentEnum.VIEW.getCode()));
predicate.add(cb.equal(root.get("groupId").as(Long.class),
sendGroupIdF));
predicate.add(cb.between(root.get("sendDate").as(Date.class),
stDateF, spDateF));
Predicate[] pre = new Predicate[predicate.size()];
return query.where(predicate.toArray(pre)).getRestriction();
}
};
return documentDao.findAll(spec, pageRequest);
}
public Page<Document> searchSendDocument(Long sendUserId, Long sendGroupId,String title,
String content, Date stDate, Date spDate, int pageNum,
int numPerPage) {
final String titl1F = title;
final String contentF = content;
final Date stDateF = stDate;
final Date spDateF = spDate;
final Long sendUserIdF = sendUserId;
final Long sendGroupIdF = sendGroupId;
Sort sort = new Sort(Direction.DESC, "id");
Pageable pageRequest = new PageRequest(pageNum - 1, numPerPage, sort);
Specification<Document> spec = new Specification<Document>() {
@Override
public Predicate toPredicate(Root<Document> root,
CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicate = new ArrayList<>();
if (titl1F != null && titl1F.trim().length() > 0) {
predicate.add(cb.like(root.get("title").as(String.class),
"%" + titl1F.trim() + "%"));
}
if (contentF != null && contentF.trim().length() > 0) {
predicate.add(cb.like(root.get("message").as(String.class),
"%" + contentF.trim() + "%"));
}
if (sendUserIdF != SearchEnum.SEARCH_ALL.getId()) {
predicate.add(cb.equal(root.get("userId").as(Long.class),
sendUserIdF));
}
predicate.add(cb.equal(root.get("isState").as(Integer.class),
DocumentEnum.VIEW.getCode()));
predicate.add(cb.equal(root.get("groupId").as(Long.class),
sendGroupIdF));
predicate.add(cb.between(root.get("sendDate").as(Date.class),
stDateF, spDateF));
Predicate[] pre = new Predicate[predicate.size()];
return query.where(predicate.toArray(pre)).getRestriction();
}
};
return documentDao.findAll(spec, pageRequest);
}
0 0
- jap 复合查询
- jap分页查询
- jap
- 复合查询
- 一个复合查询方法
- Hibernate 复合查询
- Hibernate 复合查询
- Hibernate复合查询
- 复合嵌套查询实例
- vb复合查询
- find的复合查询
- Hibernate复合主键查询
- hibernate复合查询
- SqliteOpenHelper实现复合查询
- mybatis复合查询
- thinkphp 复合条件查询
- tp的复合查询
- thinkphp-复合查询
- UVA 11361 - Investigating Div-Sum Property-数位DP
- 基于verilog的EEPROM读写
- 唯品会订单分库分表的实践总结以及关键步骤
- 程序员-前行-001-c++程序
- X86 内存布局分析(Memory map)
- jap 复合查询
- oracle存储过程和存储函数(1)
- numpy入门2
- 多年之痒,终结于今日
- Android ORM框架介绍之android-liteorm(archiver)注解与封装
- Mysql 平均值中的最小值
- (2)HTML5-内容标记方法
- SRILM使用之用平滑Katz回退训练语言模型
- IO流