-->
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: Hibernate Optimistic Locking for Concurrent Insert-possible?
PostPosted: Tue Apr 02, 2013 10:44 pm 
Newbie

Joined: Tue Apr 02, 2013 6:11 am
Posts: 2
Hi,

In one of my concurrent insert operation in the same table I'm getting the ConstraintViolationException.

Code:
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert:


Can Hibernate Optimistic Lock can help me in this regard?
As far I know that Optimistic locking work in update/delete operation on same record in the database.

Does it work for insert query as well?

I have created a version column in the target table (entity). But still getting the same exception(no optimisticLockException or StaleObjectStateException).


Top
 Profile  
 
 Post subject: Re: Hibernate Optimistic Locking for Concurrent Insert-possible?
PostPosted: Thu Apr 11, 2013 4:35 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
No, it doesn't work for inserts by principle:
optimistic Locking bases on comparing old version against new version.
To have an onld version you must have an already existing record.


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.