Skip to content

Data eager loaded by @EntityGraph is affected by where clause that filters on same relationship [DATAJPA-1746] #2040

Open
@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions