Hello all,
I use atomikos transactions for xa-transactions with hibernate.
Testing rollback of a xa-transaction over two datasources shows me an unexpected behaviour.
I use the following environment:
- hibernate 3.2.5.ga
- xa-transactions with jta (atomikos)
- a javax.transaction.UserTransaction is available in a JUnit-JNDIMock
Code:
<!-- JTA mittels ATOMIKOS -->
<prop key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
<!--
2 = TRANSACTION_READ_COMMITTED
-->
<prop key="hibernate.connection.isolation">2</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
This is what the JunitTest does:
- start two new hibernate-sessions for the two datasources and a new hibernateTransaction for each
- create new entities eA and eB for every datasource
- eA is the working one and eB has set some wrong attributes to run into a constraint-error
- persist eA and eB with the matching session
- call hibernateTransaction.commit() for each --> commit for eB throws a db-error --> HibernateException --> close the two hibernateTransactions and the two sessions.
As expected result there is no entry for eA and eB in the databases.
Now comes the irritating result:
After that, but in the same JUnit-Testmethod, I create a
new sessionB2 for datasourceB with factoryB.openSession() and try to load the not in the database existing entry for eB with sessionB2.get(type.toString(), (Serializable) keyValue);
But the new session finds an entry for eB! How is this possible? There is no secold-level cache activated.
And: if I try to debug this: then it works...
It would be very nice, if someone could give me a hint, what I'm doing wrong.
greetings