-->
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: session.lock() semantics
PostPosted: Wed Jan 14, 2004 2:41 pm 
Regular
Regular

Joined: Wed Sep 03, 2003 9:56 pm
Posts: 58
Hi,

I need to be able to grant exclusive access to a persistant object in our object model to a single user. I intend to use session.lock(theObj, LockMode.UPGRADE_NOWAIT), but I'm a bit confused as to how this works. Could someone answer the following questions for me?

1) Does calling session.lock() automatically re-SELECT the specified object with the "FOR UPDATE NOWAIT" clause?
1a) If not, should I call theObj.refresh() following the session.lock() call to ensure valid data?
2) Will a HibernateException be thrown by session.lock() if another session currently holds a lock on this object (row)?
3) Does committing my transaction release the lock, or do I need to explicitly call session.lock() again with a lower isolation level?

FWIW, I have read many threads regarding letting the DB take care of locking for me, and I believe that I have a valid case for explicit locking. I'm happy to share if need be.


--------------------------------------------------------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 2:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Please don't crosspost the forums. http://forum.hibernate.org/viewtopic.php?t=927081


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 2:47 pm 
Regular
Regular

Joined: Wed Sep 03, 2003 9:56 pm
Posts: 58
Understood.

My intention was not to cross-post. I inadvertently posted to the architecture forum after landing there following extensive searching.

Since this is hardly an architectural issue, I decided to post it where it actually belongs.

Sorry.


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.