For example, Department (Dept) has many employees (Emp) and sales deparment has 5 employees:
- in HQL:
from Dept d join fetch d.emps where d.name = 'sales'will return 5 exact same department records, each with totally initialized employees - in mapping:
<set name="emps" table="EMP" inverse="true" fetch="join">will only return 1 department with 5 initialized employees. This works as expected.
One possible workaround is using setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY). This works, although I feel they should fix it in the core.
Also see: http://glueclue.blogspot.com/2006/02/hibernate-duplicates-with-join-fetch.html
No comments:
Post a Comment