HHH-6647: requesting an upgraded lock when looking for the last audit record to make sure the same one isn't found by two concurrent transactions

This commit is contained in:
Adam Warski 2011-09-12 09:01:33 +02:00
parent 6df15ef85a
commit 53626310cf
1 changed files with 4 additions and 2 deletions

View File

@ -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<Object> l = qb.toQuery(session).list();
List<Object> 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<Object> l = qb.toQuery(session).list();
final List<Object> 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