openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
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.


Hi,
> 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.



Hi,

  I have the following code for delete

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

		}
		catch (Exception e) {
			e.printStackTrace();
		}
		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 "com.org.member.Name-us.
com.org.member.Name-902" to the data store.  This indicate
s that the object was concurrently modified in another transaction.
FailedObject: com.org.member.Name-com.org.member.Name-902

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. 

Thanks,
JP






-----
Pinaki Poddar                      http://ppoddar.blogspot.com/
                                      
http://www.linkedin.com/in/pinakipoddar
OpenJPA PMC Member/Committer
JPA Expert Group Member
-- 
View this message in context: http://n2.nabble.com/Optimistic-locking-exception-while-performing-a-delete-tp2566822p2578991.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message