-->
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: Pessimistic lock with many sessions
PostPosted: Wed Oct 15, 2003 4:08 pm 
Newbie

Joined: Wed Oct 15, 2003 3:20 pm
Posts: 9
Location: Montreal
Hi,

We are working on a j2ee platform with struts, we are using threadlocal for stroing hibernate session and we open and close a that session for each action on the client side.
I am wondering if we can use pessimistic lock when openning and closing the session between each action (eg getUser() - > saveUser()).
Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 15, 2003 4:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Do you mean you open a session in request #1 (i.e., display user for edit) and then reuse it during request #2 (i.e., save posted changes)?

OR are you opening/closing a session during each http request?

All the databases I know of are going to release write locks after the transaction under which the lock was acquired commits or the session (jdbc session) which issued the write lock closes. So this would be a problem with scenario #2.

And even with the first option, you'd run into issues with (hopefully only) the database row being locked during "user think time". I say hopefully, because I don't think all databases support row-level locks, meaning multiple rows or even the whole table would get locked. This is not a scalable solution either way.

The other option here would be to utilize optomistic locks and managing the versioning using Hibernate or in the app itself.


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.