Fixed 33772. Remove double query by saving .list() result
authorStefan Hühner <stefan.huehner@openbravo.com>
Tue, 23 Aug 2016 17:20:57 +0200
changeset 30134 b7fdb632c2b6
parent 30133 ed70d2867dd8
child 30135 9bef81691611
Fixed 33772. Remove double query by saving .list() result

instead of calling .count() and then .list() which does 2 selects for the same.
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java	Tue Aug 23 16:42:13 2016 +0200
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java	Tue Aug 23 17:20:57 2016 +0200
@@ -19,6 +19,7 @@
 package org.openbravo.userinterface.selector;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.enterprise.context.ApplicationScoped;
@@ -87,7 +88,8 @@
       obc.add(Restrictions.eq(SelectorField.PROPERTY_OBUISELSELECTOR, sel));
       obc.add(Restrictions.isNotNull(SelectorField.PROPERTY_DEFAULTEXPRESSION));
 
-      if (obc.count() == 0) {
+      List<SelectorField> selFields = obc.list();
+      if (selFields.size() == 0) {
         return result;
       }
 
@@ -103,7 +105,7 @@
           && "true".equals(params.get(SelectorConstants.DS_REQUEST_IS_FILTER_BY_ID_SUPPORTED));
       Object exprResult = null;
       JSONArray idFilters = new JSONArray();
-      for (SelectorField f : obc.list()) {
+      for (SelectorField f : selFields) {
         try {
           exprResult = engine.eval(f.getDefaultExpression());
           Object bobId = null;