Hello,
I have the associations below:
Code:
A <----> B (A->B = one-to-many, lazy=true), (B->A = many-to-one)
A <----> C (A->C = one-to-many, lazy=true), (C->A = many-to-one)
A <----> D (A->D = one-to-many, lazy=true), (D->A = many-to-one)
A <----> E (A->E = one-to-many, lazy=true), (E->A = many-to-one)
E <----> F (E->F = one-to-many, lazy=true), (F->E = many-to-one)
Because I'm working with a session disconnected from the view tier, I need to initialize the collections on DAO tier. To load the object "A" without load "F" I do this:
Code:
List result = session.find("from A");
Iterator ite = results.iterator();
while (ite.hasNext()) {
A a = (A) ite.next();
Hibernate.initialize(a.getBs());
Hibernate.initialize(a.getCs());
Hibernate.initialize(a.getDs());
Hibernate.initialize(a.getEs());
}
Is there a better way to do this job?
Thanks!