HHH-9980 - Implement mark-for-rollback-only handling for JdbcResourceLocalTransactionCoordinatorImpl

This commit is contained in:
Steve Ebersole 2015-07-24 09:58:48 -05:00
parent 7556a22c2f
commit e98f220b08
2 changed files with 9 additions and 1 deletions

View File

@ -230,7 +230,7 @@ public class JdbcResourceLocalTransactionCoordinatorImpl implements TransactionC
@Override
public TransactionStatus getStatus() {
return jdbcResourceTransaction.getStatus();
return rollbackOnly ? TransactionStatus.MARKED_ROLLBACK : jdbcResourceTransaction.getStatus();
}
@Override

View File

@ -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();
}
}