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: Optimistic concurrency
PostPosted: Thu Jun 19, 2008 10:19 pm 
Newbie

Joined: Thu Jun 19, 2008 10:02 pm
Posts: 4
I will be using Session per request pattern for my application. My question is more of a doubt on how optimistic concurrency works and less about Hibernate.
I am using a dedicated timestamp column with source="db" and generated="always".

Consider the following scenario:
User 1 in session 1 creates a new object foo and saves it. timestamp = 1 is set by DB.
User 2 in session 2 retrieves foo, updates a property of foo and saves it using session2.update. timestamp = 2 is set by DB (?)
User 1 in session 3 tries to reattach the detached object (which was created in session 1 i.e. the one with timestamp = 1) using session3.update.

Now when session3 is flushed, will Hibernate throw exception because of timestamp mismatch?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 11:03 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Each of these transactions will run in a separate thread, avoiding the type of problems you are anticipating.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.