我正在使用带有弹簧靴的jpa,对此我是新手。我有覆盖
规范的谓词toPredicate()
。下面是我的代码:-
public Predicate toPredicate(Root<ExportOrderInfo> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder builder) {
if(beginningOfQuarter != null && endOfQuarter != null){
criteriaQuery.distinct(true);
root.fetch("orderDetail", JoinType.LEFT);
root.fetch("orderDownload", JoinType.INNER);
return builder.and(builder.equal(root.<String>get(randomColumnName), valueToSearchFor) , builder.isNotNull(root.get("optyId")));
}else{
criteriaQuery.distinct(true);
root.fetch("orderDetail", JoinType.LEFT);
root.fetch("orderDownload", JoinType.LEFT);
return builder.and(builder.equal(root.<String>get(randomColumnName), valueToSearchFor));
}
}
当我使用两个root时。获取其覆盖上一个。请帮助我。