-->
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: HibernateOptimisticLockException - how to find problem?
PostPosted: Thu May 22, 2008 7:00 pm 
Newbie

Joined: Thu Jul 05, 2007 4:15 pm
Posts: 3
I inherited some code and am new to Spring and Hibernate.

1)
I have a problem where I am getting an exception in my tomcat log (HibernateOptimisticLockingFailureException)
and believe it is this:

Thread1: A line of code reads some data from the DB (a row from a table) into a hibernate ojbect
Thread2: thread2 comes along and writes some data to the table and row that was read by thread1
Thread1: thread1 then makes some change to a field in the object and tries to write to the DB

Is this the scenario that is causing this problem? Can anyone confirm this or is there some other
scenario that would cause the problem?

Would doing a "merge" instead of an "update" on both of the rows in thread 1 and thread 2 solve the issue?

---
2)
Is doing a merge the appropriate thing to do here? I am trying to find out more about the concept of "merge". I googled it but there was no detailed explanation.

---
3)
Also where can I find the *line* of code in thread 1 that read the data and tried
to save it after thread 2 beat thread 1 to it. The lines listed in the stack trace stop
way before any save to the database ocurrs. Because hibernate wraps everything, I believe
there is some lower level jdbc debug statements that I am missing.


Top
 Profile  
 
 Post subject: merge concept
PostPosted: Fri May 23, 2008 12:38 am 
Newbie

Joined: Thu May 22, 2008 6:45 am
Posts: 2
Location: Bangalore
http://www.hibernate.org/hib_docs/entit ... state.html
Please have a look into the above link to understand the merge() usage.


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.