-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DATAJPA-1033 Support projections on methods that take a Specification #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… Specification (JpaSpecificationExecutor)
…mpleJpaRepository
Projections make sense everywhere, but makes more sense when you are paging and sorting and working with filters to draw tables. This is a must to have feature. |
I've tried it and works like a charm. I've implemented a GraphQL => Spring.Specification (pageable) mapper, which can create dynamic DB queries from the given GraphQL request. My only problem was when I first want to obtain the ids for the given page - because of the Specification - not only the ids are returned. I've 4M+ rows to page, without this projection implementation the query took about 10 secs, but with the projection it took 0.2 sec. This is a MUST HAVE feature for Spring! :) |
This would be so helpful, as the amount of data you want to show to the user is mostly much smaller, than the data that can be queried. Essentially you receive a ton of data that you don't really need. Decreasing the traffic would be quite helpful to speed up almost any application. |
Hey guys, will it be merged in 2.6.0 ? I think it will be greate useful for apps. |
I'm wondering if we need this somewhat intrusive addition in light of #2274. List<UserProjectionInterfaceBased> users = repository.findBy(userHasFirstnameLike("v"), q -> q.as(UserProjectionInterfaceBased.class).all()); |
Upon further review, and in light of #2274, we are declining this feature request. Spring Data JPA's fluent API, along with it's Specification focus, supports projections right now. I realize this original request was in light of Spring Data JPA's But since #2274 was a new feature, it's only found in Spring Data JPA Please check out Spring Data JPA's |
Related JIRA issue.
The current state of this PR does not yet cover projections for
QuerydslJpaPredicateExecutor
. But it does support projections for methods that accept aSpecification
.While this is still a work-in-progress, I'd appreciate feedback/help/suggestions from the community.
In a nutshell, the methods in
JpaSpecificationExecutor
were overloaded with one that accepts a projection type.