-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Rrepository query methods with 'join fetch' produce duplicated parent entities [DATAJPA-1299] #1623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Jens Schauder commented From the JPA Specification 4.4.5.3 Fetch Joins:
Therefore it is to be expected that the variants with a I still have to look in the projection variant |
Jens Schauder commented For the projection variant two things are "interesting"
|
Jens Schauder commented I created an issue for #2: https://hibernate.atlassian.net/browse/HHH-12489 lets see what they say about it |
Jens Schauder commented The Hibernate team doesn't consider this a bug on their side |
Hayrol Reyes commented To solve a similar situation I used "query.distinct(true);" as pointed in the description. I decided to use it because my use case is a generic filter API and this will be applied to all entities' filters related to the API... also, after several tests about performance I found there wasn't any significant impact in the results. In fact, this approach also worked on Projections and Pageable results within Sorts |
I'm afraid that according to the results from https://hibernate.atlassian.net/browse/HHH-12489, this is currently considered "Works as Designed" per the existing JPA specs. If you wish to attempt to alter the specs, please visit jakartaee/persistence#177 and upvote this proposed change. If this moves forward, feel free to come back and pursue changing Spring Data JPA in the future. |
Sergei Poznanski opened DATAJPA-1299 and commented
Repository query methods with 'join fetch' leads to the duplicate parents.
Number of duplicates corresponds to the number of nested children.
To work around this situation we can use 'distinct' in the query. But this still does not work with projections.
The similar methods with
@EntityGraph
work as expected.Example:
More tests is here
Affects: 2.0.5 (Kay SR5)
Reference URL: https://github.com/Cepr0/duplicate-parent-entities
1 votes, 4 watchers
The text was updated successfully, but these errors were encountered: