diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java b/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java index b9a9cdadb0..c2edc22b4e 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/strategy/ValidityAuditStrategy.java @@ -3,6 +3,8 @@ import java.io.Serializable; import java.util.Date; import java.util.List; import java.util.Map; + +import org.hibernate.LockOptions; import org.hibernate.Session; import org.hibernate.envers.RevisionType; import org.hibernate.envers.configuration.AuditConfiguration; @@ -71,7 +73,7 @@ public class ValidityAuditStrategy implements AuditStrategy { addEndRevisionNullRestriction(auditCfg, qb); @SuppressWarnings({"unchecked"}) - List l = qb.toQuery(session).list(); + List l = qb.toQuery(session).setLockOptions(LockOptions.UPGRADE).list(); updateLastRevision(session, auditCfg, l, id, auditedEntityName, revision); } @@ -100,7 +102,7 @@ public class ValidityAuditStrategy implements AuditStrategy { addEndRevisionNullRestriction(auditCfg, qb); - final List l = qb.toQuery(session).list(); + final List l = qb.toQuery(session).setLockOptions(LockOptions.UPGRADE).list(); // Update the last revision if one exists. // HHH-5967: with collections, the same element can be added and removed multiple times. So even if it's an