HHH-10807 - Added isActive to Transaction and moved logic to TransactionDriver.
This commit is contained in:
parent
a8bcedecbf
commit
e7933ababb
|
@ -38,6 +38,16 @@ public interface Transaction extends EntityTransaction {
|
|||
*/
|
||||
TransactionStatus getStatus();
|
||||
|
||||
/**
|
||||
* Indicate whether a resource transaction is in progress.
|
||||
*
|
||||
* @param isMarkedRollbackConsideredActive whether to consider {@link TransactionStatus#MARKED_ROLLBACK} as active.
|
||||
*
|
||||
* @return boolean indicating whether transaction is in progress
|
||||
* @throws HibernateException if an unexpected error condition is encountered.
|
||||
*/
|
||||
boolean isActive(boolean isMarkedRollbackConsideredActive);
|
||||
|
||||
/**
|
||||
* Register a user synchronization callback for this transaction.
|
||||
*
|
||||
|
|
|
@ -103,7 +103,16 @@ public class TransactionImpl implements TransactionImplementor {
|
|||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return getStatus() == TransactionStatus.ACTIVE || getStatus() == TransactionStatus.MARKED_ROLLBACK;
|
||||
// old behavior considered TransactionStatus#MARKED_ROLLBACK as active
|
||||
return isActive( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(boolean isMarkedForRollbackConsideredActive) {
|
||||
if ( transactionDriverControl == null ) {
|
||||
transactionDriverControl = transactionCoordinator.getTransactionDriverControl();
|
||||
}
|
||||
return transactionDriverControl.isActive( isMarkedForRollbackConsideredActive );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -121,6 +121,12 @@ public interface TransactionCoordinator {
|
|||
|
||||
void markRollbackOnly();
|
||||
|
||||
default boolean isActive(boolean isMarkedRollbackConsideredActive) {
|
||||
final TransactionStatus status = getStatus();
|
||||
return TransactionStatus.ACTIVE == status
|
||||
|| ( isMarkedRollbackConsideredActive && TransactionStatus.MARKED_ROLLBACK == status );
|
||||
}
|
||||
|
||||
// todo : org.hibernate.Transaction will need access to register local Synchronizations.
|
||||
// depending on how we integrate TransactionCoordinator/TransactionDriverControl with
|
||||
// org.hibernate.Transaction that might be best done by:
|
||||
|
|
|
@ -191,6 +191,11 @@ public class BatchModeTransactionCoordinator implements TransactionCoordinator {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(boolean isMarkedRollbackConsideredActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionStatus getStatus() {
|
||||
return transactionDriver.getStatus();
|
||||
|
|
Loading…
Reference in New Issue