spring-projects / spring-projects/spring-data-jpa
Data eager loaded by @EntityGraph is affected by where clause that filters on same relationship [DATAJPA-1746]
@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
Jonathon Henderson opened DATAJPA-1746 and commented
When using the @EntityGraph annotation to eager load a relation during a query, a "where" clause applied to that same relation causes the eagerly loaded relation data to also be affected by that where clause.
e.g. Given an Article and Tag with a many-to-many relationship between them. A method on the ArticleRepository named findAllByTagsIn, annotated with @EntityGraph(attributePaths = {"tags"}) would result in a query that properly filters articles to only retrieve those that have the given tags. However, the eagerly loaded tags would only include those that were passed to the method when it was called, rather than all of the tags associated with each article.
See the StackOverflow link for more details
Affects: 2.3.1 (Neumann SR1)
Reference URL: https://stackoverflow.com/questions/62434684/jpa-entity-graph-eager-loading-affected-by-where-clause
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.