标签:ace exec nbsp epo dao uil err ring over
没什么好说的,记住就行。
下面是在Service中的方法
Page<TStaff> staffs=dao.findAll(new Specification<TStaff>() { @Override public Predicate toPredicate(Root<TStaff> root, CriteriaQuery<?> query, CriteriaBuilder cb) { Predicate predicate = cb.conjunction(); List<Expression<Boolean>> expressions = predicate.getExpressions(); if(StringUtils.isNotEmpty(loginName)){ expressions.add(cb.equal(root.<String>get("loginName"), loginName)); } if(StringUtils.isNotEmpty(email)){ expressions.add(cb.equal(root.get("email").as(String.class), email)); } if(StringUtils.isNotEmpty(groupDn)){ expressions.add(cb.like(root.<String>get("groupDn"), "%"+groupDn)); } return predicate; } }, new PageRequest(page.getCurPage(), page.getPageSize()));
dao定义如下:
public interface StaffDao extends Repository<TStaff, String>,JpaSpecificationExecutor<TStaff>
标签:ace exec nbsp epo dao uil err ring over
原文地址:http://www.cnblogs.com/amushen/p/6032008.html