Search in sources :

Example 1 with TransactionRequiredForJoinException

use of org.hibernate.resource.transaction.TransactionRequiredForJoinException in project hibernate-orm by hibernate.

the class AbstractBasicJtaTestScenarios method explicitJoinOutsideTxnTest.

@Test
@SuppressWarnings("EmptyCatchBlock")
public void explicitJoinOutsideTxnTest() throws Exception {
    // pre conditions
    final TransactionManager tm = JtaPlatformStandardTestingImpl.INSTANCE.transactionManager();
    assertEquals(Status.STATUS_NO_TRANSACTION, tm.getStatus());
    final JtaTransactionCoordinatorImpl transactionCoordinator = buildTransactionCoordinator(false);
    assertEquals(Status.STATUS_NO_TRANSACTION, tm.getStatus());
    // try to force a join, should fail...
    try {
        transactionCoordinator.explicitJoin();
        fail("Expecting explicitJoin() call outside of transaction to fail");
    } catch (TransactionRequiredForJoinException expected) {
    }
}
Also used : TransactionRequiredForJoinException(org.hibernate.resource.transaction.TransactionRequiredForJoinException) TransactionManager(javax.transaction.TransactionManager) JtaTransactionCoordinatorImpl(org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl) Test(org.junit.Test)

Aggregations

TransactionManager (javax.transaction.TransactionManager)1 TransactionRequiredForJoinException (org.hibernate.resource.transaction.TransactionRequiredForJoinException)1 JtaTransactionCoordinatorImpl (org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl)1 Test (org.junit.Test)1