Hello,
Using Hibernate 3.2 and trying to form HQL left joins to load collection fields along with the target object. My queries are working fine using the where clause, ordering, etc, until I start using the "left join" command and then I start getting multple entries of the same object back in my query results list.
Am I doing something wrong?
This HQL query returns one Usrprofile object as I would expect:
Code:
from Usrprofiles as usrprof where (usrprof.username='johndoe')
as there is only one "johndoe" in my Usrprofile table. However, when I try to also load one of Usrprofiles properties that is an association to another table/class using the left join, I get 6 records back. In this case, I am trying to get the single Usrprofile object for "johndoe" as well as all "Usrmsgs" associated with this user, using the following HQL:
Code:
select usrprof from Usrprofiles as usrprof left join fetch usrprof.usrmsgses where (usrprof.username="johndoe" and usrprof.usrmsgses.viewed=false) order by usrprof.usrmsgses.logDate desc
All the six objects from the second HQL line are identical.
Any help or thougths you have on this would be a great help.
Thanks,
-Matt