Hi, I have a simple one to many relation between MachineClass and MachineDataInstance tables. There are 6 entries in the MachineClass. I want to write a query that will get me a list of 6 MachineClass objects and initialize the Set member variable of all the related MachineDataInstance instances.
So I use the following query:
[code]
List list = session.createQuery("select distinct(mc) " +
"from MachineClass as mc " +
"left join fetch mc.MachineDataInstanceSet mdis").list();
[/code]
This however just gives me a list of a lot more than 6 objects that I expect. In fact for every related object in MachineDataInstance it duplicates the MachineClass in the list. So if I have only machine class "A" and 1999, 2000,2001 instances I get a list of size 3 (not what I want).
Why isn't this working for me? I want to get the data back in the way I put it into the database using a simple query.
Thanks.
|