Skip to content

Commit dadc43a

Browse files
csabokalukasz-antoniak
authored andcommitted
HHH-7800: Fixed "maximize" doesn't work inside a disjunction issue
1 parent cd33631 commit dadc43a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuil
5959

6060
CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, propertyName);
6161

62+
// Make sure our conditions are ANDed together even if the parent Parameters have a different connective
63+
Parameters subParams = parameters.addSubParameters(Parameters.AND);
6264
// This will be the aggregated query, containing all the specified conditions
6365
QueryBuilder subQb = qb.newSubQueryBuilder();
6466

6567
// Adding all specified conditions both to the main query, as well as to the
6668
// aggregated one.
6769
for (AuditCriterion versionsCriteria : criterions) {
68-
versionsCriteria.addToQuery(auditCfg, entityName, qb, parameters);
70+
versionsCriteria.addToQuery(auditCfg, entityName, qb, subParams);
6971
versionsCriteria.addToQuery(auditCfg, entityName, subQb, subQb.getRootParameters());
7072
}
7173

@@ -79,6 +81,6 @@ public void addToQuery(AuditConfiguration auditCfg, String entityName, QueryBuil
7981
}
8082

8183
// Adding the constrain on the result of the aggregated criteria
82-
parameters.addWhere(propertyName, "=", subQb);
84+
subParams.addWhere(propertyName, "=", subQb);
8385
}
8486
}

0 commit comments

Comments
 (0)