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