Author: doogie
Date: Sun Jun 26 19:15:40 2011 New Revision: 1139919 URL: http://svn.apache.org/viewvc?rev=1139919&view=rev Log: FIX/OPTIMIZE: Do column-name munging once, and save the output, instead of doing it each time the sql string is generated. This solidifies the definition of getColValue() and getColName(). colName is the identifier used to refer to the column, it's generally what comes after the AS keyword. colValue is used to the left of AS, and in CONDITION/ORDER BY/GROUP BY clauses. This change should allow EntityFieldValue to be rewritten, so it doesn't have the hack of having to deal with the entityAliasStack. In theory, it can just call getColName/getColValue(I'm not certain which is the correct one for this case). Also, EntityFieldValue should not have that hack at all, it should have been put into a completely separate class. Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=1139919&r1=1139918&r2=1139919&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Sun Jun 26 19:15:40 2011 @@ -165,13 +165,13 @@ public class SqlJdbcUtil { condBuffer.append(viewLink.getEntityAlias()); condBuffer.append("."); - condBuffer.append(filterColName(linkField.getColName())); + condBuffer.append(linkField.getColName()); condBuffer.append(" = "); condBuffer.append(viewLink.getRelEntityAlias()); condBuffer.append("."); - condBuffer.append(filterColName(relLinkField.getColName())); + condBuffer.append(relLinkField.getColName()); } if (condBuffer.length() == 0) { throw new GenericModelException("No view-link/join key-maps found for the " + viewLink.getEntityAlias() + " and the " + viewLink.getRelEntityAlias() + " member-entities of the " + modelViewEntity.getEntityName() + " view-entity."); @@ -258,7 +258,7 @@ public class SqlJdbcUtil { ModelField modelField = null; if (item instanceof ModelField) { modelField = (ModelField) item; - sb.append(modelField.getColName()); + sb.append(modelField.getColValue()); name = modelField.getName(); } else { sb.append(item); @@ -347,7 +347,7 @@ public class SqlJdbcUtil { } whereString.append(viewLink.getEntityAlias()); whereString.append("."); - whereString.append(filterColName(linkField.getColName())); + whereString.append(linkField.getColName()); // check to see whether the left or right members are optional, if so: // oracle: use the (+) on the optional side @@ -362,7 +362,7 @@ public class SqlJdbcUtil { whereString.append(viewLink.getRelEntityAlias()); whereString.append("."); - whereString.append(filterColName(relLinkField.getColName())); + whereString.append(relLinkField.getColName()); } } } else { @@ -402,13 +402,13 @@ public class SqlJdbcUtil { ModelField curField = fieldsIter.next(); sql.append(curField.getColValue()); sql.append(" AS "); - sql.append(filterColName(curField.getColName())); + sql.append(curField.getColName()); while (fieldsIter.hasNext()) { curField = fieldsIter.next(); sql.append(", "); sql.append(curField.getColValue()); sql.append(" AS "); - sql.append(filterColName(curField.getColName())); + sql.append(curField.getColName()); } } sql.append(makeFromClause(modelEntity, modelFieldTypeReader, datasourceInfo)); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java?rev=1139919&r1=1139918&r2=1139919&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelViewEntity.java Sun Jun 26 19:15:40 2011 @@ -479,7 +479,8 @@ public class ModelViewEntity extends Mod field.type = aliasedField.type; field.validators = aliasedField.validators; - field.colName = alias.entityAlias + "." + SqlJdbcUtil.filterColName(aliasedField.colName); + field.colValue = alias.entityAlias + "." + SqlJdbcUtil.filterColName(aliasedField.colName); + field.colName = SqlJdbcUtil.filterColName(field.colValue); if (UtilValidate.isEmpty(field.description)) { field.description = aliasedField.description; } |
Free forum by Nabble | Edit this page |