spring-data-jpa
spring-data-jpa copied to clipboard
Add support for combining @EntityGraph and Specification<T> [DATAJPA-1824]
Ruslan Stelmachenko opened DATAJPA-1824 and commented
Currently you can extend JpaSpecificationExecutor
and use it's methods that support Specification<T>
argument.
You can also create custom methods in repository interface with @EntityGraph
annotation to control fetching of entity attributes.
But what is missing is the ability to combine Specification<T>
argument and @EntityGraph
annotation in custom methods. To make it work spring-data-jpa should support custom methods with Specification<T>
argument (in addition to methods already present in JpaSpecificationExecutor
).
The reason why this is important: Specification<T>
defines the "where" (conditions) part of a query, while @EntityGraph
defines the "select" (what fields to fetch) part of a query. So they are 2 independent things which can work together complementing each other.
The same is actually true for Projections. They define "what fields to fetch", but usually it's not enough because service layer must also pass a predicate to instruct repository layer on "what conditions to use"
Affects: 2.4.1 (2020.0.1)
Is this new feature still in the process?
Is this new feature still in the process?
@TinyStorm for your information a library https://github.com/Cosium/spring-data-jpa-entity-graph allow you to combine the two. But I reckon that it would be great if it was vanilla.
Hows the progress in this feature? Currently its the most upvoted issue