HHH-9859 - ResourceLocalTransactionCoordinatorImpl#isJoined bad impl
This commit is contained in:
parent
0ea03fd9a4
commit
b272080645
|
@ -83,8 +83,8 @@ public class JdbcResourceLocalTransactionCoordinatorImpl implements TransactionC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isJoined() {
|
public boolean isJoined() {
|
||||||
log.debug( "Calling TransactionCoordinator#isJoined in resource-local mode always returns false" );
|
return physicalTransactionDelegate != null && physicalTransactionDelegate.getStatus() == TransactionStatus.ACTIVE;
|
||||||
return isActive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TransactionJoiningTest extends AbstractJPATest {
|
public class JtaTransactionJoiningTest extends AbstractJPATest {
|
||||||
@Override
|
@Override
|
||||||
public void configure(Configuration cfg) {
|
public void configure(Configuration cfg) {
|
||||||
super.configure( cfg );
|
super.configure( cfg );
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
|
*/
|
||||||
|
package org.hibernate.test.jpa.txn;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
|
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
||||||
|
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl;
|
||||||
|
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||||
|
import org.hibernate.testing.junit4.ExtraAssertions;
|
||||||
|
import org.hibernate.test.jpa.AbstractJPATest;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class ResourceLocalTransactionJoiningTest extends AbstractJPATest {
|
||||||
|
@Override
|
||||||
|
public void configure(Configuration cfg) {
|
||||||
|
super.configure( cfg );
|
||||||
|
TestingJtaBootstrap.prepare( cfg.getProperties() );
|
||||||
|
cfg.setProperty(
|
||||||
|
AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY,
|
||||||
|
JdbcResourceLocalTransactionCoordinatorBuilderImpl.class.getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Largely a copy of {@link org.hibernate.test.jpa.txn.TransactionJoiningTest}
|
* Largely a copy of {@link org.hibernate.test.jpa.txn.JtaTransactionJoiningTest}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue