/**
* All customers with an {@link Account} expiring before the given date.
*
* @param date
* @return
*/
public static Specification<Customer> accountExpiresBefore(final LocalDate date) {
return new Specification<Customer>() {
@Override
public Predicate toPredicate(Root<Customer> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
Root<Account> accounts = query.from(Account.class);
Path<Date> expiryDate = accounts.<Date> get("expiryDate");
Predicate customerIsAccountOwner = cb.equal(accounts.<Customer> get("customer"), root);
Predicate accountExpiryDateBefore = cb.lessThan(expiryDate, date.toDateTimeAtStartOfDay().toDate());
return cb.and(customerIsAccountOwner, accountExpiryDateBefore);
}
};
}
CustomerSpecifications.java 文件源码
java
阅读 63
收藏 0
点赞 0
评论 0
项目:spring-data-examples
作者:
评论列表
文章目录