[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: TransactionRolledBackLocalException accessing entity bea

jaysperk do-not-reply at jboss.com
Mon Nov 6 11:48:51 EST 2006


After alot of research, I have come to the following conclusion.  Performing a rollback does not rollback any changes made to a CMR relationship altered in concurrent transactions.  The changes made to the database seem to be rolled back, but the entity that contains the CMR relationship will still contain the association. 

Entity of type A has one to many relationship with Entity of type B

Start Transaction 1
Load Entity A1
Create Entity B1
Add Entity B1 to Entity A1 CMR relationship
Suspend Transaction 1
Start Transaction 2
Create Entity B2
Add Entity B2 to Entity A1
Rollback Transaction 2
Resume Transaction 1
Call CMR relationship to get B entities from A1
Returns RelationSet with 2 Entities
Get NoSuchObjectLocalException when accesing CMP field from entity B2 found in the returned RelationSet because the creation of B2 was rolled back but the relationship between A1 and B2 still existed in memory.

Conclusion:
The CMR relationship is not being cleaned up when Transaction 2 is rolled back.  Transaction 1
will get a RelationSet that contains a reference to the rolled back entity B2.

If you use the per transaction entity instance cache (to jboss.xml below)
<instance-cache>org.jboss.ejb.plugins.PerTxEntityInstanceCache</instance-cache> 
You will avoid the problem because each transaction is working on a separate instance
of the entity.  This won't work for us however, because you also would not see commits
that occurred in transaction 2, within transaction 1.

Is anyone familiar with this problem?  Or does anyone know of a workaround?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983494#3983494

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983494



More information about the jboss-user mailing list