svn commit: r808824 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: datasource/GenericDAO.java util/EntityListIterator.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r808824 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: datasource/GenericDAO.java util/EntityListIterator.java

lektran
Author: lektran
Date: Fri Aug 28 09:13:01 2009
New Revision: 808824

URL: http://svn.apache.org/viewvc?rev=808824&view=rev
Log:
Fix to make sure the ELI count handles distinct queries

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=808824&r1=808823&r2=808824&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Fri Aug 28 09:13:01 2009
@@ -758,7 +758,7 @@
                 Debug.logTiming("Ran query in " + queryTotalTime + " milli-seconds: " + sql, module);
             }
         }
-        return new EntityListIterator(sqlP, modelEntity, selectFields, modelFieldTypeReader, this, whereEntityCondition, havingEntityCondition);
+        return new EntityListIterator(sqlP, modelEntity, selectFields, modelFieldTypeReader, this, whereEntityCondition, havingEntityCondition, findOptions.getDistinct());
     }
     
     protected StringBuilder makeConditionWhereString(ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException {

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java?rev=808824&r1=808823&r2=808824&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityListIterator.java Fri Aug 28 09:13:01 2009
@@ -61,15 +61,16 @@
     protected GenericDAO genericDAO = null;
     protected EntityCondition whereCondition = null;
     protected EntityCondition havingCondition = null;
+    protected boolean distinctQuery = false;
 
     private boolean haveShowHasNextWarning = false;
     private Integer resultSize = null;
 
     public EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader) {
-        this(sqlp, modelEntity, selectFields, modelFieldTypeReader, null, null, null);
+        this(sqlp, modelEntity, selectFields, modelFieldTypeReader, null, null, null, false);
     }
 
-    public EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader, GenericDAO genericDAO, EntityCondition whereCondition, EntityCondition havingCondition) {
+    public EntityListIterator(SQLProcessor sqlp, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader, GenericDAO genericDAO, EntityCondition whereCondition, EntityCondition havingCondition, boolean distinctQuery) {
         this.sqlp = sqlp;
         this.resultSet = sqlp.getResultSet();
         this.modelEntity = modelEntity;
@@ -78,6 +79,7 @@
         this.genericDAO = genericDAO;
         this.whereCondition = whereCondition;
         this.havingCondition = havingCondition;
+        this.distinctQuery = distinctQuery;
     }
 
     public EntityListIterator(ResultSet resultSet, ModelEntity modelEntity, List<ModelField> selectFields, ModelFieldTypeReader modelFieldTypeReader) {
@@ -521,7 +523,12 @@
     public int getResultsSizeAfterPartialList() throws GenericEntityException {
         if (genericDAO != null) {
             if (resultSize == null) {
-                resultSize = (int) genericDAO.selectCountByCondition(modelEntity, whereCondition, havingCondition, null);
+                EntityFindOptions efo = null;
+                if (distinctQuery) {
+                    efo = new EntityFindOptions();
+                    efo.setDistinct(distinctQuery);
+                }
+                resultSize = (int) genericDAO.selectCountByCondition(modelEntity, whereCondition, havingCondition, efo);
             }
             return resultSize;
         } else if (this.last()) {