-->
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: Concurrent updates to an entity an its collections
PostPosted: Fri Jun 24, 2011 3:08 pm 
Newbie

Joined: Fri Jun 24, 2011 2:22 pm
Posts: 4
Hi! I'm new to the forum and I want to ask a question that maybe is simple but I don't have so much experience with hibernate. I'm using hibernate 3.3 with session beans in a Jboss environment (JTA). I'm in a situation where there could be cocurrent updates to an entitiy and sometimes some changes aren't commited to the database, and no exception is thrown. They simple don't run.

Basically my scheme is these.

-Session bean has methods 1 and 2.
-Entity has two collection of objects (A and B).
-Method 1 updates objet in collection A of the entity E.
-Method 2 updates objet in collection B of the entity E.
-For performance and usage reasons the entity E is in memory and only update to DB when changed.

When both methods 1 and 2 are call almost concurrently, some changes to an entity aren't commit; I post a simple trace to try to show the problem.

1) One client call session bean method 1.
2) Method 1 updates a child object of collection A in the entity E.
3) Method 1 ends processing entity E and calls session.saveOrUpdate(E), but do some other work not related to hibernate.
4) BEFORE method 1 exits and the commit is really execute, another client call session bean method 2.
5) Method 2 take the entity (that was in memory) and updated a child object of collection B and call session.saveOrUpdate(E).
6) Method 2 finish BEFORE method 1, and commits its changes to the entity. Changes in collection B are persisted, but not collection A changes.
7) Method 1 finish and commits, but changes in collection A aren't persisted.

Of course, if not called concurrently, both collections commits its changes well (isn't a cascade problem).

Could anyone point me some direction to investigate the problem further? I suppose maybe is some kind of locking or session flushing or clearing without commiting, but as I don't get exceptions I don't know where to look.

Thanks in advance and I hope the problem is understood.


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.