diff --git a/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java b/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java index 455fb0c94c..5ee02959ba 100644 --- a/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java +++ b/framework/entity/src/org/ofbiz/entity/model/DynamicViewEntity.java @@ -60,6 +60,9 @@ public class DynamicViewEntity { /** List of aliases with information in addition to what is in the standard field list */ protected List aliases = new ArrayList(); + /** List of fields to group by */ + protected List groupBy; + /** List of view links to define how entities are connected (or "joined") */ protected List viewLinks = new ArrayList(); @@ -211,4 +214,14 @@ public class DynamicViewEntity { public void addAllRelationsToList(List addList) { addList.addAll(this.relations); } + + public void setGroupBy(List groupBy) { + this.groupBy = groupBy; + } + + public void addAllGroupByFieldsToList(List addList) { + if (groupBy != null) { + addList.addAll(this.groupBy); + } + } } diff --git a/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java b/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java index 06956dc2a6..dba4e56e12 100644 --- a/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java +++ b/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java @@ -88,6 +88,9 @@ public class ModelViewEntity extends ModelEntity { /** A List of the Field objects for the View Entity, one for each GROUP BY field */ protected List groupBys = FastList.newInstance(); + /** List of field names to group by */ + protected List groupByFields = FastList.newInstance(); + protected Map> conversions = FastMap.newInstance(); protected ViewEntityCondition viewEntityCondition = null; @@ -165,6 +168,8 @@ public class ModelViewEntity extends ModelEntity { // relations dynamicViewEntity.addAllRelationsToList(this.relations); + dynamicViewEntity.addAllGroupByFieldsToList(this.groupByFields); + // finalize stuff // note that this doesn't result in a call to populateReverseLinks because a DynamicViewEntity should never be cached anyway, and will blow up when attempting to make the reverse links to the DynamicViewEntity this.populateFieldsBasic(modelReader); @@ -430,7 +435,7 @@ public class ModelViewEntity extends ModelEntity { field.description = alias.description; // if this is a groupBy field, add it to the groupBys list - if (alias.groupBy) { + if (alias.groupBy || groupByFields.contains(alias.name)) { this.groupBys.add(field); }