-->
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.  [ 8 posts ] 
Author Message
 Post subject: how to handle classic dual update data locking issue
PostPosted: Fri Oct 15, 2004 11:10 am 
Newbie

Joined: Fri Oct 15, 2004 11:00 am
Posts: 4
we have a web appliation using stateless session beans which hit an oracle database. we're interested in solving the issue where user 1 brings up and order update page, and then user 2 brings up an order update page for the same order, user 2 changes data and submits the changes, then user 1 changes data and submits the changes. right now we're using the "last one to submit, wins" strategy.

i'm after general common solutions as well as any pointers on how hibernate could be used in this respect. currently our slsb uses pojo and roll your own rdbms access. i imagine using hibernate would help with more than the data locking issue, but that's one project we have on the board right now.

thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 15, 2004 11:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what happens if the first user deletes the data?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 15, 2004 11:33 am 
Newbie

Joined: Fri Oct 15, 2004 11:00 am
Posts: 4
actually, in our system, we're not deleting data, but that's a very good question. under our current architecture, if we could delete data, user 2 would delete the order, and then user 1 would try to update the order. we're using bad practice and thus our EJB would throw a SQLException at that point i believe. user 1 would see a ugly SYSTEM ERROR OCCURRED page with a hidden java stack trace.

i think in a more rich client arcitecture perhaps, user 2 (who should only see a read only copy of the data and not be aloud to update or change the order till user 1 is done ) would be able to register a listener and be notified once user 1 is finished with the item. then their screen would be converted to an update screen. i suppose this thing could be done via browser interface as well. under the delete circumstance, user 2 would be notified that the record has been deleted.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 15, 2004 11:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
well if you accept having a critical error for user 2, just do nothing.
Without versionning, the system will act as you want: the last wil win

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 15, 2004 12:03 pm 
Newbie

Joined: Fri Oct 15, 2004 11:00 am
Posts: 4
that's the problem, the critical error isn't acceptable, and neither is the fact that user 2 and user 1 both will have a display showing them that they can both update the same record. you mentioned versioning. i guess that's something i'll need to look into.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 15, 2004 12:25 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
with versionning: the fisrt will win

if you want the second to be told "something else may be updating your data, you need pessimistic lock" --> not recomanded

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 17, 2004 8:19 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
What do you want to happen?

User 1 locks record then goes for coffee
...
User 2 may not touch record until User 1 comes back from coffe break
...
User 2 goes in search of User 1 with a baseball bat
...

Versioning will just stop this scenario:
User 1 reads record then gets interruped by Pointy-Haired-Boss.
...
User 2 reads record, then updates record.
...
User 1 updates record with old details (User 2's update is lost)
...
User 2 discovers User 1 stomped on his update, goes in search of User 1 with a baseball bat
...


True story.

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 18, 2004 3:34 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
or you chosse "optimistic lock" which will work (sure tricky, if you can't use versioning, but at least in my case necessary and doable) with different sessions, too. Then everybody can read and changes will be detected. No need of pessimistic locks.

sure, using "optimisitc lock" the client must be able to handle concurrency-situations ... perhaps displaying changes of user1 and user2 ...

gtx
curio


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