1. 程式人生 > >Spring-data-jpa 之Specification in的用法

Spring-data-jpa 之Specification in的用法

//根據競買人客戶名稱進行查詢
            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); } }