Closed spring-projects-issues closed 4 years ago
Marcel Overdijk opened DATAJPA-267 and commented
As mentioned in http://blog.springsource.org/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/ the querydsl api gives an an almost fluent english readable query.
E.g.
QCustomer customer = QCustomer.customer; LocalDate today = new LocalDate(); BooleanExpression customerHasBirthday = customer.birthday.eq(today); BooleanExpression isLongTermCustomer = customer.createdAt.lt(today.minusYears(2)); customerRepository.findAll(customerHasBirthday.and(isLongTermCustomer));
In my own project I added a static where() helper to make this even more readable. The the call would look like:
customerRepository.findAll(where(customerHasBirthday).and(isLongTermCustomer));
Not only it reads as "find all where" but also not each predicate is not in it's own brackets.
The static helper I used for this is:
public static BooleanBuilder where(Predicate predicate) { return new BooleanBuilder(predicate); }
Please consider adding this to Spring Data.
Additionally this would also be more in line when using Specifications. It's the equivalent for http://static.springsource.org/spring-data/data-jpa/docs/current/api/org/springframework/data/jpa/domain/Specifications.html#where(org.springframework.data.jpa.domain.Specification).
Affects: 1.2 GA
1 votes, 1 watchers
Jens Schauder commented
I don't think this adds enough benefit to carry its weight especially since anybody interested in having this might just add it themselves
Marcel Overdijk opened DATAJPA-267 and commented
As mentioned in http://blog.springsource.org/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/ the querydsl api gives an an almost fluent english readable query.
E.g.
In my own project I added a static where() helper to make this even more readable. The the call would look like:
Not only it reads as "find all where" but also not each predicate is not in it's own brackets.
The static helper I used for this is:
Please consider adding this to Spring Data.
Additionally this would also be more in line when using Specifications. It's the equivalent for http://static.springsource.org/spring-data/data-jpa/docs/current/api/org/springframework/data/jpa/domain/Specifications.html#where(org.springframework.data.jpa.domain.Specification).
Affects: 1.2 GA
1 votes, 1 watchers