From dadc43af23b1e8dd8623abc66a9ff6864993bc14 Mon Sep 17 00:00:00 2001 From: Csaba Varga Date: Wed, 21 Nov 2012 14:30:07 +0100 Subject: [PATCH] HHH-7800: Fixed "maximize" doesn't work inside a disjunction issue --- .../envers/query/criteria/AggregatedAuditExpression.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java b/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java index 4be8b5d617..1f4003e9d8 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/AggregatedAuditExpression.java @@ -59,13 +59,15 @@ public class AggregatedAuditExpression implements AuditCriterion, ExtendableCrit CriteriaTools.checkPropertyNotARelation(auditCfg, entityName, propertyName); + // Make sure our conditions are ANDed together even if the parent Parameters have a different connective + Parameters subParams = parameters.addSubParameters(Parameters.AND); // This will be the aggregated query, containing all the specified conditions QueryBuilder subQb = qb.newSubQueryBuilder(); // Adding all specified conditions both to the main query, as well as to the // aggregated one. for (AuditCriterion versionsCriteria : criterions) { - versionsCriteria.addToQuery(auditCfg, entityName, qb, parameters); + versionsCriteria.addToQuery(auditCfg, entityName, qb, subParams); versionsCriteria.addToQuery(auditCfg, entityName, subQb, subQb.getRootParameters()); } @@ -79,6 +81,6 @@ public class AggregatedAuditExpression implements AuditCriterion, ExtendableCrit } // Adding the constrain on the result of the aggregated criteria - parameters.addWhere(propertyName, "=", subQb); + subParams.addWhere(propertyName, "=", subQb); } } \ No newline at end of file