Spring-data-jpa 之Specification in的用法
阿新 • • 發佈:2019-02-03
//根據競買人客戶名稱進行查詢 In<Long> in = cb.in(root.get(BailPay_.customerId)); if(customerName != null && !customerName.isEmpty()){ List<Customer> customerList = customerRepository.findAllByCustomerName(customerName); if (customerList != null && customerList.size()>0) { for (Customer customer : customerList) { if (customer != null) { in.value(customer.id());} } predicates.add(in); }else{ Predicate predicateCustomerId = cb.equal(root.get(BailPay_.customerId), 0L); predicates.add(predicateCustomerId); } }