HHH-12540 - Reusing same EntityTransaction with JTA enabled

This commit is contained in:
Andrea Boriero 2018-05-04 09:44:09 +01:00 committed by Steve Ebersole
parent ca86633370
commit ecd6f503f8
4 changed files with 12 additions and 7 deletions

View File

@ -212,6 +212,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
}
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
transactionCoordinator.invalidate();
}
@Override

View File

@ -2741,6 +2741,7 @@ public final class SessionImpl
@Override
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) {
super.removeSharedSessionTransactionObserver( transactionCoordinator );
transactionCoordinator.removeObserver( transactionObserver );
}

View File

@ -118,7 +118,6 @@ public class JtaTransactionCoordinatorImpl implements TransactionCoordinator, Sy
synchronizationRegistered = false;
pulse();
}
/**
@ -337,6 +336,14 @@ public class JtaTransactionCoordinatorImpl implements TransactionCoordinator, Sy
return this.timeOut;
}
@Override
public void invalidate() {
if ( physicalTransactionDelegate != null ) {
physicalTransactionDelegate.invalidate();
}
physicalTransactionDelegate = null;
}
// SynchronizationCallbackTarget ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
@ -377,11 +384,6 @@ public class JtaTransactionCoordinatorImpl implements TransactionCoordinator, Sy
observer.afterCompletion( successful, delayed );
}
if ( physicalTransactionDelegate != null ) {
physicalTransactionDelegate.invalidate();
}
physicalTransactionDelegate = null;
synchronizationRegistered = false;
}
@ -394,7 +396,6 @@ public class JtaTransactionCoordinatorImpl implements TransactionCoordinator, Sy
observers.remove( observer );
}
/**
* Implementation of the LocalInflow for this TransactionCoordinator. Allows the
* local transaction ({@link org.hibernate.Transaction} to callback into this

View File

@ -106,6 +106,8 @@ public interface TransactionCoordinator {
return isJoined() && getTransactionDriverControl().isActive( isMarkedRollbackConsideredActive );
}
default void invalidate(){}
/**
* Provides the means for "local transactions" (as transaction drivers) to control the
* underlying "physical transaction" currently associated with the TransactionCoordinator.