Search in sources :

Example 1 with JdbcResourceLocalTransactionCoordinatorImpl

use of org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl in project hibernate-orm by hibernate.

the class ResourceLocalTransactionJoiningTest method testExpectations.

@Test
@TestForIssue(jiraKey = "HHH-9859")
public void testExpectations() {
    // JPA spec is very vague on what should happen here.  It does vaguely
    // imply that javax.persistence.EntityManager.joinTransaction() should only be used
    // for JTA EMs, however it does not enforced that nor does the TCK check that.
    // And the TCK in fact does test calls to javax.persistence.EntityManager.isJoinedToTransaction()
    // from resource-local EMs, so lets make sure those work..
    Session session = sessionFactory().openSession();
    JdbcResourceLocalTransactionCoordinatorImpl tc = ExtraAssertions.assertTyping(JdbcResourceLocalTransactionCoordinatorImpl.class, ((SessionImplementor) session).getTransactionCoordinator());
    assertFalse(tc.isJoined());
    session.beginTransaction();
    tc = ExtraAssertions.assertTyping(JdbcResourceLocalTransactionCoordinatorImpl.class, ((SessionImplementor) session).getTransactionCoordinator());
    assertTrue(tc.isJoined());
    session.getTransaction().rollback();
    session.close();
}
Also used : SessionImplementor(org.hibernate.engine.spi.SessionImplementor) JdbcResourceLocalTransactionCoordinatorImpl(org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl) Session(org.hibernate.Session) Test(org.junit.Test) AbstractJPATest(org.hibernate.test.jpa.AbstractJPATest) TestForIssue(org.hibernate.testing.TestForIssue)

Aggregations

Session (org.hibernate.Session)1 SessionImplementor (org.hibernate.engine.spi.SessionImplementor)1 JdbcResourceLocalTransactionCoordinatorImpl (org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl)1 AbstractJPATest (org.hibernate.test.jpa.AbstractJPATest)1 TestForIssue (org.hibernate.testing.TestForIssue)1 Test (org.junit.Test)1