Title
h

hyukchan

01/25/2019, 2:23 PM
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

Lamberto Basti

01/25/2019, 2:25 PM
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

hyukchan

01/25/2019, 2:28 PM
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