日期:2014-05-17 浏览次数:20753 次
public Page<Order> findPage(Member member, Pageable pageable) {
if(member == null) {
return new Page(Collections.emptyList(), 0L, pageable);
}
CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
CriteriaQuery<Order> cq = cb.createQuery(Order.class);
Root<Order> root = cq.from(Order.class);
cq.select(root);
cq.where(cb.equal(root.get("member"), member));
return super.findPage(cq, pageable);
}
public Page<OrderPack> findPage(OrderStatus orderStatus, Boolean isAllPostalInConfirmed, Set<Storage> storages, Pageable pageable) {
CriteriaBuilder cb = this.entityManager.getCriteriaBuilder();
CriteriaQuery<OrderPack> cq = cb.createQuery(OrderPack.class);
Root root = cq.from(OrderPack.class);
cq.select(root);
Predicate predicate = cb.conjunction();
if (orderStatus != null) {
predicate = cb.and(predicate, cb.equal(root.get("orderStatus"), orderStatus));
}
if(isAllPostalInConfirmed != null) {
predicate = cb.and(predicate,cb.equal(root.get("isAllPostalInConfirmed"), isAllPostalInConfirmed));
}
if(storages != null && !storages.isEmpty()) {
predicate = cb.and(predicate, root.get("storage").in(storages));
}
cq.where(predicate);
return findPage(cq, pageable);
}
public Page<Postal> findPage(Member member, Pageable pageable) {
if (member == null)
return new Page(Collections.emptyList(), 0L, pageable);
CriteriaBuilder localCriteriaBuilder = this.entityManager.getCriteriaBuilder();
CriteriaQuery localCriteriaQuery = localCriteriaBuilder.createQuery(Postal.class);
Root localRoot = localCriteriaQuery.from(Postal.class);
localCriteriaQuery.select(localRoot);
localCriteriaQuery.where(localCriteriaBuilder.equal(localRoot.join("member"), member));
return super.findPage(localCriteriaQuery, pageable);
}