Hi guys, I'm trying to use JPA specification with ...
# announcements
h
Hi guys, I'm trying to use JPA specification with kotlin, but I'm having compilation errors... Has anyone have good example to show ?
l
Have a look here! https://github.com/lamba92/taass-backend/tree/master/src/main/kotlin/it/unito/projector It's a bit old but it should work. It implements a REST repository backed by a db on AWS
h
Hi thanks for your quick response. Though I'm more looking for something like this:
public CustomerSpecifications { public static Specification<Customer> customerHasBirthday() { return new Specification<Customer> { public Predicate toPredicate(Root<T> root, CriteriaQuery query, CriteriaBuilder cb) { return cb.equal(root.get(Customer_.birthday), today); } }; } public static Specification<Customer> isLongTermCustomer() { return new Specification<Customer> { public Predicate toPredicate(Root<T> root, CriteriaQuery query, CriteriaBuilder cb) { return cb.lessThan(root.get(Customer_.createdAt), new LocalDate.minusYears(2)); } }; } }
Thanks for your help anyway
👍 1
515 Views