diff --git a/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java index 48757c7941..4e4191d023 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/transaction/backend/jdbc/internal/JdbcResourceLocalTransactionCoordinatorImpl.java @@ -230,7 +230,7 @@ public class JdbcResourceLocalTransactionCoordinatorImpl implements TransactionC @Override public TransactionStatus getStatus() { - return jdbcResourceTransaction.getStatus(); + return rollbackOnly ? TransactionStatus.MARKED_ROLLBACK : jdbcResourceTransaction.getStatus(); } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/resource/transaction/jdbc/BasicJdbcTransactionTests.java b/hibernate-core/src/test/java/org/hibernate/test/resource/transaction/jdbc/BasicJdbcTransactionTests.java index d78030dc53..316bc06a75 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/resource/transaction/jdbc/BasicJdbcTransactionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/test/resource/transaction/jdbc/BasicJdbcTransactionTests.java @@ -10,6 +10,7 @@ import org.hibernate.TransactionException; import org.hibernate.resource.transaction.TransactionCoordinator; import org.hibernate.resource.transaction.TransactionCoordinatorBuilder; import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl; +import org.hibernate.resource.transaction.spi.TransactionStatus; import org.hibernate.test.resource.common.SynchronizationCollectorImpl; import org.junit.Test; @@ -69,14 +70,21 @@ public class BasicJdbcTransactionTests { } ); + assertEquals( TransactionStatus.NOT_ACTIVE, transactionCoordinator.getTransactionDriverControl().getStatus() ); + transactionCoordinator.getTransactionDriverControl().begin(); + assertEquals( TransactionStatus.ACTIVE, transactionCoordinator.getTransactionDriverControl().getStatus() ); + transactionCoordinator.getTransactionDriverControl().markRollbackOnly(); + assertEquals( TransactionStatus.MARKED_ROLLBACK, transactionCoordinator.getTransactionDriverControl().getStatus() ); + try { transactionCoordinator.getTransactionDriverControl().commit(); } catch (TransactionException expected) { } finally { + assertEquals( TransactionStatus.MARKED_ROLLBACK, transactionCoordinator.getTransactionDriverControl().getStatus() ); transactionCoordinator.getTransactionDriverControl().rollback(); } }