-->
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 in concurrent EJB calls (JTA)
PostPosted: Tue Jul 05, 2011 12:13 am 
Newbie

Joined: Fri Jun 24, 2011 2:22 pm
Posts: 4
I'm using hibernate 3.3 with session beans in a Jboss environment (JTA). I have an EJB that has two methods that can be called concurrently by two clients, and both methods can update different fields of a Person entity.

Because of concurrency I'm having same lost updates in the associate collections of my entity because of the commit order (that of course I don't manage cause is part of the JTA transactions). One example for ilustration.

1) Client A calls method 1. Method 1 update one object of 'addresses' collection in my Person object.
2) Client B calls method 2. Method 2 and add one object to the 'items' collection in my Person object.
3) Both methods exit almost concurrently, but method 2 commit first and updates of method 1 in the 'addresses' collection are lost and doesn't show any errors.

The person object is in memory and not retrieved in every method call, but is update with session.update(person) at first. Is there any thing I can do to manage this use case, and assure that commit of method 1 is call first?
I suppose Lock.UPGRADE isn't a solution cause I'm having problems with the associations and not the object per se.

Thanks in advance and sorry for my english!


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.