diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/synchronization/AuditProcess.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/synchronization/AuditProcess.java index dd52e2a86f..b3c96fb12c 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/synchronization/AuditProcess.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/synchronization/AuditProcess.java @@ -20,10 +20,14 @@ import org.hibernate.envers.internal.revisioninfo.RevisionInfoGenerator; import org.hibernate.envers.internal.synchronization.work.AuditWorkUnit; import org.hibernate.envers.tools.Pair; +import org.jboss.logging.Logger; + /** * @author Adam Warski (adam at warski dot org) */ public class AuditProcess implements BeforeTransactionCompletionProcess { + private static final Logger log = Logger.getLogger( AuditProcess.class ); + private final RevisionInfoGenerator revisionInfoGenerator; private final SessionImplementor session; @@ -124,6 +128,11 @@ public class AuditProcess implements BeforeTransactionCompletionProcess { 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 if ( FlushMode.isManualFlushMode( session.getFlushMode() ) ) { Session temporarySession = null;