-
May 12th, 2012, 01:32 AM
#1
how to use JpaSpecificationExecutor ?? I'm new thank you
in docs i see this
public class CustomerSpecs {
public static Specification<Customer> isLongTermCustomer() {
return new Specification<Customer>() {
Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
CriteriaBuilder builder) {
LocalDate date = new LocalDate().minusYears(2);
return builder.lessThan(root.get(Customer_.createdAt), date);
}
};
}
public static Specification<Customer> hasSalesOfMoreThan(MontaryAmount value) {
return new Specification<Customer>() {
Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
CriteriaBuilder builder) {
// build query here
}
};
}
}
and use it
List<Customer> customers = customerRepository.findAll(isLongTermCustomer());
my question is isLongTermCustomer() is a static method ,why used it like this?
i think that it used like CustomerSpecs.isLongTermCustomer()
There are other reasons
who can give me a demo,thank you very much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules