If I have 2 classes:
@Entity
public class Court {
@Id
private long id;
@OneToMany(targetEntity=Judge.class,
fetch=FetchType.LAZY,
cascade = CascadeType.ALL,
mappedBy = "court")
private Set<Judge> judges;
}
@Entity
public class Judge {
@Id
private long id;
}
And I have 4 rows in the Court table and 8 in the Judges table (2 for each court) and I execute the following:
String s = "select distinct c from Court c left outer join fetch c.judges";
List l = em.createQuery(s).getResultList();
System.out.println(l.size());
This prints out 8, where it I think it should print out 4. From section 4.8 of the jsr220 spec:
The DISTINCT keyword is used to specify that duplicate values
must be eliminated from the query result. If DISTINCT is not specified,
duplicate values are not eliminated.
If I run the same query in hibernate it prints out the value 4.
What is the correct behaviour?
Regards,
Michael Barker.
[Message sent by forum member 'mikebarker' (mikebarker)]
http://forums.java.net/jive/thread.jspa?messageID=204097