Fix TransactionJoiningTest

This commit is contained in:
Andrea Boriero 2016-05-03 17:58:26 +01:00 committed by Steve Ebersole
parent 2a252d5015
commit 2e1d1a6f16
3 changed files with 35 additions and 9 deletions

View File

@ -34,6 +34,7 @@ public class TransactionImpl implements TransactionImplementor {
public TransactionImpl(TransactionCoordinator transactionCoordinator, ExceptionConverter exceptionConverter) { public TransactionImpl(TransactionCoordinator transactionCoordinator, ExceptionConverter exceptionConverter) {
this.transactionCoordinator = transactionCoordinator; this.transactionCoordinator = transactionCoordinator;
this.exceptionConverter = exceptionConverter; this.exceptionConverter = exceptionConverter;
transactionDriverControl = transactionCoordinator.getTransactionDriverControl();
} }
@Override @Override

View File

@ -335,9 +335,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
@Override @Override
public void markForRollbackOnly() { public void markForRollbackOnly() {
if ( currentHibernateTransaction != null ) { accessTransaction().markRollbackOnly();
currentHibernateTransaction.markRollbackOnly();
}
} }
@Override @Override

View File

@ -847,10 +847,9 @@ public final class SessionImpl
private Object fireMerge(MergeEvent event) { private Object fireMerge(MergeEvent event) {
checkOpen(); checkOpen();
checkTransactionSynchStatus();
checkNoUnresolvedActionsBeforeOperation();
try { try {
checkTransactionSynchStatus();
checkNoUnresolvedActionsBeforeOperation();
for ( MergeEventListener listener : listeners( EventType.MERGE ) ) { for ( MergeEventListener listener : listeners( EventType.MERGE ) ) {
listener.onMerge( event ); listener.onMerge( event );
} }
@ -872,9 +871,9 @@ public final class SessionImpl
private void fireMerge(Map copiedAlready, MergeEvent event) { private void fireMerge(Map copiedAlready, MergeEvent event) {
checkOpen(); checkOpen();
checkTransactionSynchStatus();
try { try {
checkTransactionSynchStatus();
for ( MergeEventListener listener : listeners( EventType.MERGE ) ) { for ( MergeEventListener listener : listeners( EventType.MERGE ) ) {
listener.onMerge( event, copiedAlready ); listener.onMerge( event, copiedAlready );
} }
@ -958,20 +957,48 @@ public final class SessionImpl
private void fireDelete(DeleteEvent event) { private void fireDelete(DeleteEvent event) {
checkOpen(); checkOpen();
try{
checkTransactionSynchStatus(); checkTransactionSynchStatus();
for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) { for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
listener.onDelete( event ); listener.onDelete( event );
} }
delayedAfterCompletion(); }
catch ( ObjectDeletedException sse ) {
throw exceptionConverter.convert( new IllegalArgumentException( sse ) );
}
catch ( MappingException e ) {
throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( RuntimeException e ) {
//including HibernateException
throw exceptionConverter.convert( e );
}
finally {
delayedAfterCompletion();
}
} }
private void fireDelete(DeleteEvent event, Set transientEntities) { private void fireDelete(DeleteEvent event, Set transientEntities) {
checkOpen(); checkOpen();
try{
checkTransactionSynchStatus(); checkTransactionSynchStatus();
for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) { for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
listener.onDelete( event, transientEntities ); listener.onDelete( event, transientEntities );
} }
delayedAfterCompletion(); }
catch ( ObjectDeletedException sse ) {
throw exceptionConverter.convert( new IllegalArgumentException( sse ) );
}
catch ( MappingException e ) {
throw exceptionConverter.convert( new IllegalArgumentException( e.getMessage(), e ) );
}
catch ( RuntimeException e ) {
//including HibernateException
throw exceptionConverter.convert( e );
}
finally {
delayedAfterCompletion();
}
} }