You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Book Entity which has many-to-many relationships with entities Author and Publisher. To fetch the Book entity and its relations in one query, I am using entity views. The Book entity view returned by the query unexpectedly contains duplicate objects.
This issue appears to be very similar to issue #660 .
lmbuchholz
changed the title
Use of multiple @ManyToMany associations returns duplicate items in list
Use of multiple @ManyToMany associations returns duplicate objects in list
Nov 28, 2024
I have a Book Entity which has many-to-many relationships with entities Author and Publisher. To fetch the Book entity and its relations in one query, I am using entity views. The Book entity view returned by the query unexpectedly contains duplicate objects.
This issue appears to be very similar to issue #660 .
Description
Model classes
Repository
Entity Views
Expected behavior
The returned BookView will look as follows, with no objects duplicated:
Actual behavior
When my program executes the findByTitle method from the repository mentioned above, the publisher object is duplicated:
Note that if I use JPARepository and the entity classes (rather than entity views), this list of books is generated correctly.
Steps to reproduce
Execute the findByTitle method from the repository mentioned above.
Environment
Java 21.0.4 2024-07-16 LTS
Spring Boot 3.3.3
Hibernate 6.5.2.Final
MySQL connector 8.0.2
The text was updated successfully, but these errors were encountered: