I currently use the following code:
Code:
List list = session.find("from Supplier as supplier where supplier.id=1");
Supplier supplier = (Supplier) list.get(0);
Hibernate.initialize(supplier.getContacts());
The initialization is necessary because I use the contacts collection after the hibernate session is closed and I don't want to use non-lazy initialization.
However, it would be nice if I could specify the initialization of the collection in the HQL query. Is this possible?
I read something about the "fetch" keyword, but I don't yet understand if that is what I need in this situation.
Thanks.