| Given this entity class plus a matching Child class
public class Parent {
@OneToMany(mappedBy = "parent")
private List<Child> children;
}
This em.createQuery("select distinct p from Parent p left join fetch p.children").getResultList(); yields a number of results equal to the number of Parents, as expected. But this em.createQuery("select distinct p from Parent p left join fetch p.children", Tuple.class).getResultList() yields a number of results equal to the number of children if there are more than one child. There is an executable demonstration of the issue: https://github.com/schauder/duplicate-parent-entities/blob/master/src/test/java/io/github/cepr0/demo/repo/EmTest.java |