epbernard wrote:
select a, b, c from A as a left outer join a.Bs b left outer join b.Cs c
Doing this depends on the average row size of your 3 tables - cause you will return rowcount(A) * rowcount(B) * rowcount(C) records.
One single query, but may return a huge amount of data - B being duplicated as many times you have corresponding C's, and A duplicated as many times you got duplicate Bs...
We had the same problem, and the only solution we found was to retrieve the collections ourselves using 3 different HQL queries:
Code:
session.query("from A where <your a criteria>");
session.query("select b from A a left outer join a.Bs b where <your a criteria>");
session.query("select c from A a left outer join a.Bs b left outer join b.Cs c where <your a criteria>");
Unfortunately, doing so will not initialize the collections in A and B. So if you later call A.getBs() - you will hit the database again :-(
On the other hand, it gives you the opportunity to retrieve only properties of B & C you actually need...