HHH-9685 - Envers should do nothing when JTA transaction is already marked as rollback-only

(cherry picked from commit a6f3319eaf)
This commit is contained in:
Steve Ebersole 2015-09-30 00:34:33 -05:00
parent 3305c71fbc
commit b2c9724905
1 changed files with 9 additions and 0 deletions

View File

@ -20,10 +20,14 @@ import org.hibernate.envers.internal.revisioninfo.RevisionInfoGenerator;
import org.hibernate.envers.internal.synchronization.work.AuditWorkUnit; import org.hibernate.envers.internal.synchronization.work.AuditWorkUnit;
import org.hibernate.envers.tools.Pair; import org.hibernate.envers.tools.Pair;
import org.jboss.logging.Logger;
/** /**
* @author Adam Warski (adam at warski dot org) * @author Adam Warski (adam at warski dot org)
*/ */
public class AuditProcess implements BeforeTransactionCompletionProcess { public class AuditProcess implements BeforeTransactionCompletionProcess {
private static final Logger log = Logger.getLogger( AuditProcess.class );
private final RevisionInfoGenerator revisionInfoGenerator; private final RevisionInfoGenerator revisionInfoGenerator;
private final SessionImplementor session; private final SessionImplementor session;
@ -124,6 +128,11 @@ public class AuditProcess implements BeforeTransactionCompletionProcess {
return; return;
} }
if ( !session.getTransactionCoordinator().isActive() ) {
log.debug( "Skipping envers transaction hook due to non-active (most likely marked-rollback-only) transaction" );
return;
}
// see: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431 // see: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431
if ( FlushMode.isManualFlushMode( session.getFlushMode() ) ) { if ( FlushMode.isManualFlushMode( session.getFlushMode() ) ) {
Session temporarySession = null; Session temporarySession = null;