| When using EAGER fetching in @OneToMany realtionship and @ElementCollection in a related entity, the returned data is multiplied. Consider following case with a tree like structure: We have entities A (root), B (nodes) and C (additional data of B). A has relationship @OneToOne to B. B has relationship @OneToMany to B and @OneToOne to C. C has @ElementCollection (a map). In the B parent entity is a list of B children. If the relationship is eager then elements on the list are multiplied as many times as there are elements in C's @ElementCollection. Workaround: If you annotate @OneToMany eager relationship with @org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT) the problem will not occur. I will provide Hibernate ORM 5 Test Case shortly. |