-->
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.  [ 3 posts ] 
Author Message
 Post subject: Adding to a non-initialised PersistentSet out of session?
PostPosted: Mon Dec 01, 2008 8:35 am 
Beginner
Beginner

Joined: Thu Oct 16, 2008 11:19 am
Posts: 23
Location: Norway
I have a problem. I need to add an object to a set belonging to a persistent object to take advantage of the cascade="save-update" on it. The set however was not used when the persistent object was in session, so it is just a proxy (non-initialised) and I get a LazyInitializationException, which is natural. I don't want the set to be loaded non-lazily though, and I don't need to know what the set contains. I just want to be able to somehow attach an object to it so that it will automatically be saved. Is there a way to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2008 9:11 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
No. The Set.add() method has a boolean return value and must return true if the item was added and false if the item already existed in the set. To know this the set must be initialized.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 01, 2008 9:33 am 
Beginner
Beginner

Joined: Thu Oct 16, 2008 11:19 am
Posts: 23
Location: Norway
I was afraid of that.

Thanks for the reply!


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