-->
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.  [ 1 post ] 
Author Message
 Post subject: Lost Updates / Concurrency Issues
PostPosted: Fri Jan 29, 2010 3:15 pm 
Newbie

Joined: Fri Jan 29, 2010 2:43 pm
Posts: 1
I'm having trouble understanding how I should avoid lost updates.

I have two applications:
App 1 is a tomcat stateless web service app, using the session-per-request pattern.
App 2 is a Grizzly socket-server based application that users stay connected for longer sessions, using the session-per-conversation pattern.

Both are using JPA/Hibernate for database access, and the shared database is MySQL community 5.1.40 with InnoDB tables, and REPEATABLE_READ isolation level.

Suppose a user has a session open on App Two, and posts to a web-service in App One which modifies their customer record. When App Two modifies its instance of the customer record (usually not the same properties as App One), and EntityManager.merge() is called and the transaction is committed, the updates made in App One are lost. I can see them if I do EntityManager.refresh() before the merge(), but that undoes the changes the user made in App Two and I have to re-apply the changes.

What I want is basically Optimistic Concurrency Control, but without modifying my schema to add a version property. I see that if I was using the Hibernate Annotations I could achieve this by setting:
Code:
@org.hibernate.annotations.Entity(optimisticLock = org.hibernate.annotations.OptimisticLockType.ALL)


But we are using JPA annotations everywhere else.

I also read that optimistic locking is not possible with your DB using REPEATABLE_READ? Is this true? Should I lower it to READ_COMMITTED ?

Any help is greatly appreciated!

Best,
Ryan


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.