Author: doogie
Date: Sun May 30 22:07:55 2010
New Revision: 949617

URL: http://svn.apache.org/viewvc?rev=949617&view=rev
Log:
Add new variants of makeConditionWhereString that take a StringBuilder, and 
deprecate the old versions that don't.

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=949617&r1=949616&r2=949617&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 
Sun May 30 22:07:55 2010
@@ -695,11 +695,7 @@ public class GenericDAO {
 
         // WHERE clause
         List<EntityConditionParam> whereEntityConditionParams = 
FastList.newInstance();
-        StringBuilder whereString = makeConditionWhereString(modelEntity, 
whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
-        if (whereString.length() > 0) {
-            sqlBuffer.append(" WHERE ");
-            sqlBuffer.append(whereString.toString());
-        }
+        makeConditionWhereString(sqlBuffer, " WHERE ", modelEntity, 
whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
 
         // GROUP BY clause for view-entity
         if (modelViewEntity != null) {
@@ -765,7 +761,12 @@ 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;
@@ -786,7 +787,10 @@ public class GenericDAO {
 
         String viewClause = SqlJdbcUtil.makeViewWhereClause(modelEntity, 
datasourceInfo.joinStyle);
 
-        StringBuilder whereString = new StringBuilder();
+        if (entityCondWhereString.length() > 0 || 
UtilValidate.isNotEmpty(viewEntityCondWhereString) || viewClause.length() > 0) {
+            whereString.append(prefix);
+        }
+
         if (entityCondWhereString.length() > 0) {
             boolean addParens = entityCondWhereString.charAt(0) != '(';
             if (addParens) whereString.append("(");
@@ -1040,11 +1044,7 @@ public class GenericDAO {
 
         // WHERE clause
         List<EntityConditionParam> whereEntityConditionParams = 
FastList.newInstance();
-        StringBuilder whereString = makeConditionWhereString(modelEntity, 
whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
-        if (whereString.length() > 0) {
-            sqlBuffer.append(" WHERE ");
-            sqlBuffer.append(whereString.toString());
-        }
+        makeConditionWhereString(sqlBuffer, " WHERE ", modelEntity, 
whereEntityCondition, viewWhereConditions, whereEntityConditionParams);
 
         // GROUP BY clause for view-entity
         if (isGroupBy) {


Reply via email to