You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2010/06/01 22:24:04 UTC

svn commit: r950237 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java

Author: jleroux
Date: Tue Jun  1 20:24:03 2010
New Revision: 950237

URL: http://svn.apache.org/viewvc?rev=950237&view=rev
Log:
Revert r949617 because it introduce a bug: 

2010-06-01 22:11:30,656 (http-0.0.0.0-8443-5) [  ServiceDispatcher.java:543:ERROR] Error in Service [executeFind]: Error running Find on the [ProductSearchNoNotInUse] entity: SQL Exception while executing the
 following:SELECT DISTINCT PR.PRODUCT_ID, PR.PRODUCT_TYPE_ID, PR.PRIMARY_PRODUCT_CATEGORY_ID, PR.PRODUCT_NAME FROM public.PRODUCT PR LEFT OUTER JOIN public.SUPPLIER_PRODUCT SP ON PR.PRODUCT_ID = SP.PRODUCT_ID
 WHERE  AND ((PR.PRODUCT_TYPE_ID <> ? OR PR.PRODUCT_TYPE_ID IS NULL)) ORDER BY PR.PRODUCT_NAME ASC (ERREUR: erreur de syntaxe sur ou prÞs de ½ AND +
  Position: 206)

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=950237&r1=950236&r2=950237&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 Tue Jun  1 20:24:03 2010
@@ -695,7 +695,11 @@ public class GenericDAO {
 
         // WHERE clause
         List<EntityConditionParam> whereEntityConditionParams = FastList.newInstance();
-        makeConditionWhereString(sqlBuffer, " WHERE ", modelEntity, whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
+        StringBuilder whereString = makeConditionWhereString(modelEntity, whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
+        if (whereString.length() > 0) {
+            sqlBuffer.append(" WHERE ");
+            sqlBuffer.append(whereString.toString());
+        }
 
         // GROUP BY clause for view-entity
         if (modelViewEntity != null) {
@@ -757,12 +761,7 @@ public class GenericDAO {
         return new EntityListIterator(sqlP, modelEntity, selectFields, modelFieldTypeReader, this, whereEntityCondition, havingEntityCondition, findOptions.getDistinct());
     }
 
-    @Deprecated
     protected StringBuilder makeConditionWhereString(ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException {
-        return makeConditionWhereString(new StringBuilder(), "", modelEntity, whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
-    }
-
-    protected StringBuilder makeConditionWhereString(StringBuilder whereString, String prefix, ModelEntity modelEntity, EntityCondition whereEntityCondition, List<EntityCondition> viewWhereConditions, List<EntityConditionParam> whereEntityConditionParams) throws GenericEntityException {
         ModelViewEntity modelViewEntity = null;
         if (modelEntity instanceof ModelViewEntity) {
             modelViewEntity = (ModelViewEntity) modelEntity;
@@ -783,10 +782,7 @@ public class GenericDAO {
 
         String viewClause = SqlJdbcUtil.makeViewWhereClause(modelEntity, datasourceInfo.joinStyle);
 
-        if (entityCondWhereString.length() > 0 || UtilValidate.isNotEmpty(viewEntityCondWhereString) || viewClause.length() > 0) {
-            whereString.append(prefix);
-        }
-
+        StringBuilder whereString = new StringBuilder();
         if (entityCondWhereString.length() > 0) {
             boolean addParens = entityCondWhereString.charAt(0) != '(';
             if (addParens) whereString.append("(");
@@ -1048,7 +1044,11 @@ public class GenericDAO {
 
         // WHERE clause
         List<EntityConditionParam> whereEntityConditionParams = FastList.newInstance();
-        makeConditionWhereString(sqlBuffer, " WHERE ", modelEntity, whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
+        StringBuilder whereString = makeConditionWhereString(modelEntity, whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
+        if (whereString.length() > 0) {
+            sqlBuffer.append(" WHERE ");
+            sqlBuffer.append(whereString.toString());
+        }
 
         // GROUP BY clause for view-entity
         if (isGroupBy) {