-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HQL and lazy initialization
PostPosted: Fri Oct 03, 2003 8:07 am 
Newbie

Joined: Fri Oct 03, 2003 7:56 am
Posts: 1
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 03, 2003 8:50 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
from Supplier as supplier inner join fetch supplier.contacts where supplier.id=1

Have a look at the 9.3 section of Hibernate reference guide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.