hibernate-demos icon indicating copy to clipboard operation
hibernate-demos copied to clipboard

ARJUNA017003 when using nested @Transactional(REQUIRES_NEW) in CdiJpaTest

Open duschata opened this issue 3 years ago • 1 comments

Hello All, I've modified org.hibernate.demos.jpacditesting.CdiJpaTest a litte bit and I get an ARJUNA017003 Exception:

checking transaction and found that this connection is already associated with a different transaction! Obtain a new connection for this transaction.

https://github.com/duschata/hibernate-demos/blob/ARJUNA017003/other/cdi-jpa-testing/src/test/java/org/hibernate/demos/jpacditesting/CdiJpaTest.java#L156-L184

Works this as expected or is this a bug? How can I test my services which are annotated with REQUIRES_NEW?

Kind Regards Tom

duschata avatar Jan 25 '22 06:01 duschata

Even when I'm a little late at the party, I had the same problem.

I found https://developer.jboss.org/thread/280419 suggesting to use @TransactionScoped for the EntityManager produce method and it works for me.

Maybe you also need to set the isolation level. I did that in the getConnection method of the TransactionalConnectionProvider with e.g. com.arjuna.ats.jdbc.common.jdbcPropertyManager.getJDBCEnvironmentBean().setIsolationLevel( Connection.TRANSACTION_READ_COMMITTED);

Cheers Uli

alexxismachine avatar Jul 03 '24 14:07 alexxismachine