在dao实现层或者manager层写
default List<BbwBarrage> findByEnable(int enable) {
return this.findAll(new Specification<BbwBarrage>() {
@Override
public Predicate toPredicate(Root<BbwBarrage> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
Predicate predicate;
// TODO Auto-generated method stub
Path enableP = root.get("enable");
predicate = criteriaBuilder.equal(enableP, enable);
query.where(predicate);
return predicate;
}
});
}
在controller层中直接
List<T> lists = xxManager.finaAll(xx);
分页查询也是这个套路