openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <>
Subject Re: Optimistic locking exception while performing a delete
Date Fri, 03 Apr 2009 05:08:59 GMT

1. The test case uses 
    long memberId = ((ApplicationMember)object).getApplicationMemberID();
   But no such method exists in ApplicationMember class.

2. Domain classes uses @GeneratedValue identity strategy as well as the test application tries
to set identity. That is not correct usage.

3. It was not obvious (to me) the intention behind the delete() method. It seemed that its
input is a ApplicationMember instance and it is trying to find() a ApplicationMember again
with the same id. The it creates a new Application() but does not persist it. 

Please post a consistent (i.e. to a compiler) test case + domain classes + persistence.xml
+ stack trace of the failed assertion -- and I will investigate further.

> OpenJPA intermittently gives the below exception 
*intermittently* worries me.
Post the domain classes Application+ApplicationMember with their mapping meta-data, and we
will take a look.


  I have the following code for delete

		public Object delete(Object object)throws Exception{
		Application application = null;
		Long applicationId = null; 
			long memberId = ((ApplicationMember)object).getApplicationMemberID();
			ApplicationMember member = entityManager.find(ApplicationMember.class, memberId);
			applicationId = member.getApplication().getApplicationId();
			application = new Application();

		catch (Exception e) {
		return application;

While performing the above operation, OpenJPA intermittently gives the below exception

Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error> org.apache.openjp
a.persistence.OptimisticLockException: An optimistic lock violation was detected
 when flushing object instance "" to the data store.  This indicate
s that the object was concurrently modified in another transaction.

And I have the following settings in my persistence.xml file

			<property name="openjpa.LockManager" value="pessimistic(VersionCheckOnReadLock=none,VersionUpdateOnWriteLock=none)"/>

Could some one please help me come out of this problem? I am posting after 2 days of hard
work googling all the forums. 


Pinaki Poddar            
OpenJPA PMC Member/Committer
JPA Expert Group Member
View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message