Hi,
Apologies in advance if this is a dumb question but I've been having a problem with hibernate at work that I'm unable to work out. First off a general question...
Is hibernate able to support join fetching of multiple collections so as all collections are initialised within a single selection statement. For example
A has child collections B and C
In my mind the following HQL should instantiate object A with its collections fully initialised but it doesn't seem to
from A a left join fetch a.B b left join fetch A.C c
The generated SQL seems to get all necessary data, a list of A's is created and every A has its collection B initialised but a seperate select is then run to get collection C for every A. Some possible problems that might be causing the problem..
I also have a where condition that makes reference to b and c, so the HQL now becomes - from A a left join fetch a.B b left join fetch A.C c where b.value = x and c.value = y. This is an unfortunate necessity due to mapping to a badly formed legacy DB
Secondly, B and C are actually the same object type and are defined in the same mapping under different mapping names which map to different tables in the DB, A contains seperate collection properties for the two rather than trying to splice them all into a single collection. Again this is due to badly designed tables and legacy data which I'm not responsible for nor have the power to modify.
If either of these issues could be causing my problem, is there a way around them so that I can do the whole retreival using a single select?
Many thanks in advance
|