Author: doogie
Date: Wed Jun 2 02:18:19 2010 New Revision: 950339 URL: http://svn.apache.org/viewvc?rev=950339&view=rev Log: Re-apply 949617, add new variants of makeConditionWhereString that take a StringBuilder, and deprecate the old versions that don't. This works now because of the previous commit. 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=950339&r1=950338&r2=950339&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 Wed Jun 2 02:18:19 2010 @@ -696,11 +696,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) { @@ -762,7 +758,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; @@ -780,12 +781,12 @@ public class GenericDAO { String viewClause = SqlJdbcUtil.makeViewWhereClause(modelEntity, datasourceInfo.joinStyle); - StringBuilder whereString = new StringBuilder(); if (viewClause.length() > 0) { conditions.add(EntityCondition.makeConditionWhere(viewClause)); } if (!conditions.isEmpty()) { + whereString.append(prefix); whereString.append(EntityCondition.makeCondition(conditions, EntityOperator.AND).makeWhereString(modelEntity, whereEntityConditionParams, this.datasourceInfo)); } @@ -1027,11 +1028,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) { |
Free forum by Nabble | Edit this page |