Fix a Group By bug when using Count (View Entities)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@672191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jacques Le Roux
2008-06-27 08:43:00 +00:00
parent f11fd686da
commit a8a5046719
@@ -970,7 +970,18 @@ public class GenericDAO {
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;