Hi, probally this a stupid question, but i don't found docs regarding this...
For example if i have three class A,B and C and A have a 1-n relation to B and n-n relation to C (A have to methods: getBs and getCs mapping as set with lazy attribute to true)
for load A instance without B and C (related to the particular a instance)
i use: session.load(A.class,aId);
for load A instance with B (or C) i use:
A a = (A) session.load(A.class,aId);
Hibernate.initialize(a.getBs);
for load all i use:
A a = (A) session.load(A.class,aId);
Hibernate.initialize(a.getBs);
Hibernate.initialize(a.getCs);
But if i B have a relation 1-n to D class and i would load the D class when load B for A (D are lazy loaded) how realize it?It's possible?
If i would load all a with B and C is possible using a only query or i should iterate on collection like this:
(select atmp from A as atmp) return a collection
....
while(collIT.hasNext()){
a = (A) collIT.next();
Hibernate.initialize(a.getBs);
Hibernate.initialize(a.getCs);
}
...
Thanks in advance.
Alessio
|