HHH-9980 - Implement mark-for-rollback-only handling for JdbcResourceLocalTransactionCoordinatorImpl
This commit is contained in:
parent
7556a22c2f
commit
e98f220b08
|
@ -230,7 +230,7 @@ public class JdbcResourceLocalTransactionCoordinatorImpl implements TransactionC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TransactionStatus getStatus() {
|
public TransactionStatus getStatus() {
|
||||||
return jdbcResourceTransaction.getStatus();
|
return rollbackOnly ? TransactionStatus.MARKED_ROLLBACK : jdbcResourceTransaction.getStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.hibernate.TransactionException;
|
||||||
import org.hibernate.resource.transaction.TransactionCoordinator;
|
import org.hibernate.resource.transaction.TransactionCoordinator;
|
||||||
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
import org.hibernate.resource.transaction.TransactionCoordinatorBuilder;
|
||||||
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
|
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.hibernate.test.resource.common.SynchronizationCollectorImpl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -69,14 +70,21 @@ public class BasicJdbcTransactionTests {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assertEquals( TransactionStatus.NOT_ACTIVE, transactionCoordinator.getTransactionDriverControl().getStatus() );
|
||||||
|
|
||||||
transactionCoordinator.getTransactionDriverControl().begin();
|
transactionCoordinator.getTransactionDriverControl().begin();
|
||||||
|
assertEquals( TransactionStatus.ACTIVE, transactionCoordinator.getTransactionDriverControl().getStatus() );
|
||||||
|
|
||||||
transactionCoordinator.getTransactionDriverControl().markRollbackOnly();
|
transactionCoordinator.getTransactionDriverControl().markRollbackOnly();
|
||||||
|
assertEquals( TransactionStatus.MARKED_ROLLBACK, transactionCoordinator.getTransactionDriverControl().getStatus() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
transactionCoordinator.getTransactionDriverControl().commit();
|
transactionCoordinator.getTransactionDriverControl().commit();
|
||||||
}
|
}
|
||||||
catch (TransactionException expected) {
|
catch (TransactionException expected) {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
assertEquals( TransactionStatus.MARKED_ROLLBACK, transactionCoordinator.getTransactionDriverControl().getStatus() );
|
||||||
transactionCoordinator.getTransactionDriverControl().rollback();
|
transactionCoordinator.getTransactionDriverControl().rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue