-->
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: Question about collections
PostPosted: Fri Dec 07, 2007 8:29 pm 
Newbie

Joined: Fri Dec 07, 2007 8:17 pm
Posts: 2
Hi all,
I have some persistent class and some collection in this class. For saving some element to database, I must execute
someClass.getSomeCollection().add(someElement).
But someClass.getSomeCollection() gets all elements of collection from database. Can I add element to database without getting all elements from collection?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 09, 2007 7:42 pm 
Newbie

Joined: Fri Mar 30, 2007 5:23 pm
Posts: 16
Location: New York, NY
Yes - give the collection the attribute:

Code:
lazy="extra"

That will prevent Hibernate from initializing all of the elements in the collection at once. It's not always a good idea, though - for instance, with that on, every time you call the next() method of that collection's iterator, it will require a separate query to the database. As the Hibernate manual indicates, it's primarily "suitable for very large collections". If the collection is not especially large, the amount of time required to initialize it will probably not be significant.

http://www.hibernate.org/hib_docs/v3/re ... ns-mapping


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.