spring-projects / spring-projects/spring-data-jpa
Add support for combining @EntityGraph and Specification<T> [DATAJPA-1824]
@schauder is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 3.3k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.