-->
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: 2.1.3 Session.lock() causing updates to not persist
PostPosted: Sat May 08, 2004 4:01 pm 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
I notices my changes were not being persisted to the database, and when I took away this call (right before the sess.update):

sess.lock(inObj, LockMode.NONE);

..my changes started persisting again. Could someone explain to me when this is needed, and when it is not? I causes a lot of confusion at home/work. Should we not be using it? Sometimes if we dont we get TransientObject exceptions... Thanks for any explanation.

Matt Dowell


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 08, 2004 4:04 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This call basically only reattaches a detached instance with the Session. The object can be modified after lock() and changes will be saved. However, you shouldn't have changed the detached instance while it wasn't associated with the Session.

If you manipulated the detached object, use update() to reassociate it with a new Session. Using both lock() and update() to reattach doesn't make much sense.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.