在ofbiz中创建动态视图实体

时间:2016-01-17 14:45:18

标签: ofbiz

我正在对视图实体运行查询,这会产生一些数据集。问题是我想在结果数据集上进行分组。为清楚起见,我的查询的简化版本类似于:

SELECT OBJECT1, OBJECT2 FROM MY_TABLE WHERE OBJECT3=? AND OBJECT4=? GROUP BY OBJECT1.  

此处,MY_TABLE是系统中的现有视图实体,我正在应用一些过滤器来获取相关数据。代码看起来像:

if(UtilValidate.isNotEmpty(productId)) {
              andExprs.add(EntityCondition.makeCondition("productId", productId));
            }
            if( UtilValidate.isNotEmpty(statusId) && !statusId.equalsIgnoreCase("All")) {
              andExprs.add(EntityCondition.makeCondition("statusId", statusId));
            }
            andExprs.add(EntityCondition.makeCondition(
                        EntityFunction.UPPER_FIELD("issueDate"),
                        EntityOperator.BETWEEN,
                        criteria));
            andExprsList = EntityCondition.makeCondition(andExprs,
                    EntityOperator.AND);
            quoteList = delegator
            .findListIteratorByCondition(dynamicViewForQuotesByProduct,  andExprsList,
                    null, fieldsToSelectForQuotesByProduct, null, null);  

我的问题是我如何group-byfindListIteratorByCondition返回的结果。提前谢谢!

2 个答案:

答案 0 :(得分:0)

在准备动态视图实体(在您的情况下为dynamicViewForQuotesByProduct)时,您可以在" addAlias"中指定group by," findListIteratorByCondition" hasEntityCondition,即实际上是EntityCondition对象,它指定在完成任何分组后如何约束此查询(如果这是具有分组别名的视图实体)在内部检查您传递的视图实体以及如何分组 - 查询。

答案 1 :(得分:-1)

groupBy方法将addAlias()参数的值传递为true。

相关问题