}
@SuppressWarnings({"unchecked"})
public void performCollectionChange(Session session, AuditConfiguration auditCfg,
PersistentCollectionChangeData persistentCollectionChangeData, Object revision) {
final QueryBuilder qb = new QueryBuilder(persistentCollectionChangeData.getEntityName(), MIDDLE_ENTITY_ALIAS);
// Adding a parameter for each id component, except the rev number
final String originalIdPropName = auditCfg.getAuditEntCfg().getOriginalIdPropName();
final Map<String, Object> originalId = (Map<String, Object>) persistentCollectionChangeData.getData().get(
originalIdPropName);
for (Map.Entry<String, Object> originalIdEntry : originalId.entrySet()) {
if (!auditCfg.getAuditEntCfg().getRevisionFieldName().equals(originalIdEntry.getKey())) {
qb.getRootParameters().addWhereWithParam(originalIdPropName + "." + originalIdEntry.getKey(),
true, "=", originalIdEntry.getValue());
}
}
addEndRevisionNullRestriction(auditCfg, qb.getRootParameters());
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
// ADD, we may need to update the last revision.
if (l.size() > 0) {