I thought the following code would return a list containing one Person, with that Person havig his set of addresses populated:
Code:
session.createCriteria(PersonImpl.class).setFetchMode("addresses", FetchMode.JOIN).add(Expression.eq("socialSecurityNumber", theSocialSecurityNumber)).list();
Instead I get as many Persons as there are addresses for that person. That is, instead of getting one Person holding a set of three addresses, I get a list containing three Persons, each with the same identifying information (e.g., id, socialSecurityNumber).
How can I fix the above query to get my desired result?
In case it helps, the definition of the addresses set is:
Code:
<set name ="addresses"
inverse = "true"
cascade="none"
lazy="true">
<key column ="PERSONID"/>
<one-to-many class="com.eduction.datamodel.AddressImpl"/>
</set>
I'm using hibernate version 3.0.4.