Author: jleroux
Date: Fri Jun 27 01:43:00 2008
New Revision: 672191
URL:
http://svn.apache.org/viewvc?rev=672191&view=revLog:
Fix a Group By bug when using Count (View Entities)
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.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=672191&r1=672190&r2=672191&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 Jun 27 01:43:00 2008
@@ -970,7 +970,18 @@
sqlP.executeQuery();
long count = 0;
ResultSet resultSet = sqlP.getResultSet();
- if (resultSet.next()) {
+ boolean isGroupBy = false;
+ if (modelEntity instanceof ModelViewEntity) {
+ ModelViewEntity modelViewEntity = (ModelViewEntity) modelEntity;
+ String groupByString = modelViewEntity.colNameString(modelViewEntity.getGroupBysCopy(), ", ", "", false);
+
+ if (UtilValidate.isNotEmpty(groupByString)) isGroupBy = true;
+ }
+
+ if (isGroupBy) {
+ while (resultSet.next()) count++;
+ }
+ else if (resultSet.next()) {
count = resultSet.getLong(1);
}
return count;