Support projections on repository query methods [DATAJPA-804] #1165
Comments
Thomas Darimont commented The same approach would probably also work for other stores like MongoDB and Couchbase |
Oliver Drotbohm commented I've put a bit of stuff into feature branches and the Spring Data examples project. Most of the code is in Spring Data Commons, JPA uses the new API to optimize for closed projection interfaces (i.e. ones not using dynamic properties) as well as forwarding constructor expressions for DTOs |
Chris Li commented Do we have plan when to release this useful feature? :) |
Oliver Drotbohm commented Gonna be part of upcoming Hopper M1 |
Oliver Drotbohm commented Implemented as documented in this comment |
Julian Hochstetter commented I think this issue is not fixed in the current release although it is also mentioned in the release notes but in my point of view the relevant changes remains only in the issue/DATAJPA-804 branch. |
Oliver Drotbohm commented It is. See this commit and the commit adding an example here |
Julian Hochstetter commented Ah i see, but not in the 1.9.4.RELEASE, its in 1.10.0.M1 and my fault was to rely on the 1.9.4.RELEASE changelog. |
Thomas Darimont opened DATAJPA-804 and commented
It would be cool if we could leverage the projection support recently introduced in Spring Data CMNS
for custom queries in Spring Data JPA.
This would enable some interesting use cases:
A Projection interface could serve as a view for a domain object - by simply proxying it.
This could be either a JDK proxy with the actual entity as a target or a dynamically generated
class (e.g. via ASM) that is only backed by the properties from the target domain object.
Another valid option would be to use a dedicated DTO type here with properties matching those of the entity.
We could push down the defined properties on the projection interface down to the JPA query creation
which would then only fetch the values for the properties listed on said interface. This could then be based on 1).
For a user it could look like this:
I have a prototype for this working that I'll push in a bit
Issue Links:
DATAJPA-864 Query execution fails for manually defined queries containing a constructor expression
DATACMNS-89 Support for projections in repository query methods
3 votes, 5 watchers
The text was updated successfully, but these errors were encountered: