Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Consider the following association
A <----> B <----->*C
A has a one to one relation with B
B has a one to many relation with C
I have the following query
select a, b, c from A as a inner join a.b as B left outer join b.c as C where a.attrib in ('zzz','www','yyy')
This query on execution, returns a list of Object[], with each element in the array having an instance each of A,B,C
for example, the result will be as follows
[a1, b1, c11]
[a1, b1, c12]
[a1, b1, c13]
[a2, b2, c21]
[a2, b2, c22]
[a2, b2, c23]
[a3, b3, c31]
[a3, b3, c32]
[a3, b3, c33]
Is there a way to retrieve the result in the following format (using a single EJB QL / HQL query) ?
[a1,b1, set(c1)]
[a2,b2, set(c2)]
[a3,b3, set(c3)]
where, set(c1) will contain objects c11,c12,c13 which are associated to b1 and similarly set(c2) will contain c21,c22,c23 and set(c3) will contain c31,c32,c33
The idea is basically to retrieve a group of associated objects using a single EJB QL /HQL query. Any help or pointers regarding this would help.
Thanks