svn commit: r949612 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: datasource/GenericDAO.java model/ModelViewEntity.java

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

svn commit: r949612 - in /ofbiz/trunk/framework/entity/src/org/ofbiz/entity: datasource/GenericDAO.java model/ModelViewEntity.java

doogie-3
Author: doogie
Date: Sun May 30 22:07:29 2010
New Revision: 949612

URL: http://svn.apache.org/viewvc?rev=949612&view=rev
Log:
Optimize groupBy insertion a bit, to keep from having to make a copy of the groupBy list.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.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=949612&r1=949611&r2=949612&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 Sun May 30 22:07:29 2010
@@ -980,13 +980,9 @@ public class GenericDAO {
 
         boolean isGroupBy = false;
         ModelViewEntity modelViewEntity = null;
-        String groupByString = null;
         if (modelEntity instanceof ModelViewEntity) {
             modelViewEntity = (ModelViewEntity) modelEntity;
-            groupByString = modelViewEntity.colNameString(modelViewEntity.getGroupBysCopy(), ", ", "", false);
-            if (UtilValidate.isNotEmpty(groupByString)) {
-                isGroupBy = true;
-            }
+            isGroupBy = modelViewEntity.getGroupBysSize() > 0;
         }
 
         // To get a count of the rows that will be returned when there is a GROUP BY, must do something like:
@@ -1051,10 +1047,8 @@ public class GenericDAO {
 
         // GROUP BY clause for view-entity
         if (isGroupBy) {
-            if (UtilValidate.isNotEmpty(groupByString)) {
-                sqlBuffer.append(" GROUP BY ");
-                sqlBuffer.append(groupByString);
-            }
+            sqlBuffer.append(" GROUP BY ");
+            sqlBuffer.append(modelViewEntity.colNameString(modelViewEntity.getGroupBysCopy(), ", ", "", false));
         }
 
         // HAVING clause

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=949612&r1=949611&r2=949612&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Sun May 30 22:07:29 2010
@@ -248,6 +248,10 @@ public class ModelViewEntity extends Mod
         return newList;
     }
 
+    public int getGroupBysSize() {
+        return this.groupBys.size();
+    }
+
     public List<ModelField> getGroupBysCopy() {
         return getGroupBysCopy(null);
     }