Jpa的criteriaBuilder.in使用

需求:

在原有的Jpa查询上过滤订单状态。类似于Sql: where status in (1,2,3)

Path path = root.get("status");
CriteriaBuilder.In in = criteriaBuilder.in(path);
in.value(OrderRefund.Status.pending);
in.value(OrderRefund.Status.approved);
in.value(OrderRefund.Status.received);
in.value(OrderRefund.Status.receiveing);
restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.and(in)); jpa-criteriabuilder-how-to-use-in-comparison-operator 
  

你可能感兴趣的:(Hibernate)