[Add Payment] Fixes count when no grouping (use count as is much more efficent)
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java Thu Jun 19 10:45:54 2014 +0200
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/HQLDataSourceService.java Thu Jun 19 11:46:17 2014 +0200
@@ -126,8 +126,21 @@
@Override
protected int getCount(Map<String, String> parameters) {
Table table = getTableFromParameters(parameters);
- boolean justCount = false;
+ boolean justCount = true;
Query countQuery = getQuery(table, parameters, justCount);
+ String hqlQuery = countQuery.getQueryString();
+ int nRows = -1;
+ if (hqlQuery.toUpperCase().contains(GROUPBY)) {
+ justCount = false;
+ countQuery = getQuery(table, parameters, justCount);
+ return getGroupedCount(countQuery);
+ } else {
+ nRows = ((Number) countQuery.uniqueResult()).intValue();
+ }
+ return nRows;
+ }
+
+ protected int getGroupedCount(Query countQuery) {
int nRows = -1;
ScrollableResults scrollableResults = countQuery.scroll();
if (scrollableResults.last()) {