Hi,
i use the following finder method to find a number of business objects by primary key:
Code:
public static List findByPrimaryKeys(Session pSession, List pKeys)
throws HibernateException
{
Query query = pSession.createQuery("select from BO1 as bo1 " +
"left join fetch bo1.BO2s " +
"where bo1.a in (:keys)");
query.setParameterList("keys", pKeys);
List back= query.list();
return back;
}
The query works, but unfortunately it returns duplicate bo1 objects:
if pKeys contains one primary key, and that entity has 10 BO2
children, i get a query result of 10 BO1 objects, containing the same data.
If i remove the "left join fetch bo1.BO2s" line, everything works as expected, but of course with a lower performance.
I'm using Hibernate 2.1b4.
Any hints?
Bye,
J