List<Map<String, Object>> res = null;
try{
res = parkDao.findAll(new Specification() {
@Override
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder cb) {
List<Predicate> predicateList = new ArrayList<>();
criteriaQuery.multiselect();
if (!StringUtil.isEmpty(checkStatus)) {
predicateList.add(cb.equal(root.get("checkStatus"), checkStatus));
}
if (streetOfficeCode!=null) {
predicateList.add(cb.equal(root.get("streetOfficeCode"), streetOfficeCode));
}
if (communityCode!=null) {
predicateList.add(cb.equal(root.get("communityCode"), communityCode));
}
if (departmentCode!=null) {
predicateList.add(cb.equal(root.get("departmentCode"), departmentCode));
}
log.debug("predicateList--->"+predicateList);
Predicate[] pre = new Predicate[predicateList.size()];
criteriaQuery.where(predicateList.toArray(pre));
return cb.and(predicateList.toArray(pre));
}
},new Sort(Sort.Direction.DESC,"id"));
这个代码构建了动态查询,但是查出了整个表的所有字段
我只需要其中的某些字段,该怎么办?