Fixes issue 25969: Adds properly the value of a parameter to a query object
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 12 Mar 2014 09:57:48 +0100
changeset 22689 143dbdd74f2b
parent 22688 7eaae425d5ad
child 22690 9ff7be508001
child 22691 e96b7b4d4793
Fixes issue 25969: Adds properly the value of a parameter to a query object

The value of a parameter is added to a query object only if the parameter has been actually included in the query string.
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java
--- a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java	Thu Feb 06 16:00:39 2014 +0100
+++ b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/LinkToParentTreeDatasourceService.java	Wed Mar 12 09:57:48 2014 +0100
@@ -219,6 +219,7 @@
     boolean isMultiParentTree = tableTree.isHasMultiparentNodes();
 
     StringBuilder whereClause = new StringBuilder();
+    final List<Object> queryParameters = new ArrayList<Object>();
     whereClause.append(" as e where ");
     String actualParentId = new String(parentId);
     if (isMultiParentTree) {
@@ -247,13 +248,12 @@
           whereClause.append(".id");
         }
         whereClause.append(" = ? ");
+        queryParameters.add(actualParentId);
       }
     }
     final OBQuery<BaseOBObject> query = OBDal.getInstance().createQuery(entity.getName(),
         whereClause.toString());
 
-    final List<Object> queryParameters = new ArrayList<Object>();
-    queryParameters.add(actualParentId);
     query.setParameters(queryParameters);
 
     final DataToJsonConverter toJsonConverter = OBProvider.getInstance().get(