mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
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:
parent
6df15ef85a
commit
53626310cf
@ -3,6 +3,8 @@
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.envers.RevisionType;
|
import org.hibernate.envers.RevisionType;
|
||||||
import org.hibernate.envers.configuration.AuditConfiguration;
|
import org.hibernate.envers.configuration.AuditConfiguration;
|
||||||
@ -71,7 +73,7 @@ public void perform(Session session, String entityName, AuditConfiguration audit
|
|||||||
addEndRevisionNullRestriction(auditCfg, qb);
|
addEndRevisionNullRestriction(auditCfg, qb);
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked"})
|
@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);
|
updateLastRevision(session, auditCfg, l, id, auditedEntityName, revision);
|
||||||
}
|
}
|
||||||
@ -100,7 +102,7 @@ public void performCollectionChange(Session session, AuditConfiguration auditCfg
|
|||||||
|
|
||||||
addEndRevisionNullRestriction(auditCfg, qb);
|
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.
|
// 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
|
// HHH-5967: with collections, the same element can be added and removed multiple times. So even if it's an
|
||||||
|
Loading…
x
Reference in New Issue
Block a user