-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate.initialize() does not initialize collection
PostPosted: Wed Apr 27, 2005 5:07 am 
Newbie

Joined: Tue Apr 26, 2005 10:45 am
Posts: 7
Hi all,

i cann't initialize a collection using Hibernate.initialize().
[code]
Job job = (Job) session.load(Job.class, new Integer(1));


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 5:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as far as i remember the javadoc states it does not gaurentee that the elements of the collection is initialized - its just the collection.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 5:46 am 
Newbie

Joined: Tue Apr 26, 2005 10:45 am
Posts: 7
Thanks, for the very fast response! So is there a best way to
initialize a whole collection or should i initialize each element
using a for loop?
Code:
for(JobItem item : items)
{
   Hibernate.initialize(item);
}


I cann't use eager fetching by criteria api, because there are more
collections that must be loaded eagerly.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 5:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as far as i remember the javadoc states it does not gaurentee that the elements of the collection is initialized - its just the collection.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 6:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the most efficent way is to fetch the collection with criteria or hql api.

iterating over each element is definitly the slowest way ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 7:01 am 
Newbie

Joined: Tue Apr 26, 2005 10:45 am
Posts: 7
thank you :o)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.