Page<AoaQuestionHeader> findAll(Specification<AoaQuestionHeader> spec, Pageable pageable);
List<AoaQuestionHeader> headerPage = questionHeaderDao.findAll(new Specification<AoaQuestionHeader>(){
@Override
public Predicate toPredicate(Root<AoaQuestionHeader> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if (!typeId.equals(0L)){
list.add(cb.equal(root.get("typeId").as(Long.class),typeId)) ;
}
if (!groupId.equals(0L)){
list.add(cb.equal(root.get("groupId").as(Long.class), groupId)) ;
}
if (!leaderId.equals(0L)){
list.add(cb.equal(root.get("leaderId").as(Long.class), leaderId) );
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
}, new PageRequest(page,size , sort));
List<AoaQuestionHeader> findAll(Specification<AoaQuestionHeader> spec);
List<AoaQuestionHeader> hlist = questionHeaderDao.findAll(new Specification<AoaQuestionHeader>(){
@Override
public Predicate toPredicate(Root<AoaQuestionHeader> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> list = new ArrayList<Predicate>();
if (!typeId.equals(0L)){
list.add(cb.equal(root.get("typeId").as(Long.class),typeId)) ;
}
if (!groupId.equals(0L)){
list.add(cb.equal(root.get("groupId").as(Long.class), groupId)) ;
}
if (!leaderId.equals(0L)){
list.add(cb.equal(root.get("leaderId").as(Long.class), leaderId) );
}
Predicate[] p = new Predicate[list.size()];
return cb.and(list.toArray(p));
}
});
这么个意思,自己的笔记看不懂勿用