Author: jleroux
Date: Wed Nov 4 21:56:34 2009 New Revision: 832880 URL: http://svn.apache.org/viewvc?rev=832880&view=rev Log: A patch from Matarazzo Angelo "Remove an useless EntitySubSelect warning message." (https://issues.apache.org/jira/browse/OFBIZ-3145) - OFBIZ-3145 With the same security kept Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java?rev=832880&r1=832879&r2=832880&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityConditionSubSelect.java Wed Nov 4 21:56:34 2009 @@ -106,17 +106,26 @@ } } + @Override public EntityConditionValue freeze() { return new EntityConditionSubSelect(localModelEntity, keyFieldName, (whereCond != null ? whereCond.freeze() : null), requireAll); } - + + public String getKeyFieldName() { + return this.keyFieldName; + } + + public ModelEntity getModelEntity() { + return this.localModelEntity; + } + @Override public ModelField getModelField(ModelEntity modelEntity) { // do nothing for now return null; } - + @Override public Comparable getValue(Delegator delegator, Map<String, ? extends Object> map) { // do nothing for now Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=832880&r1=832879&r2=832880&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Wed Nov 4 21:56:34 2009 @@ -280,12 +280,27 @@ if (type == null) { throw new IllegalArgumentException("Type " + curField.getType() + " not found for entity [" + modelEntity.getEntityName() + "]; probably because there is no datasource (helper) setup for the entity group that this entity is in: [" + delegator.getEntityGroupName(modelEntity.getEntityName()) + "]"); } - + if (value instanceof EntityConditionSubSelect){ + ModelFieldType valueType=null; + try { + ModelEntity valueModelEntity= ((EntityConditionSubSelect) value).getModelEntity(); + valueType = delegator.getEntityFieldType(valueModelEntity, valueModelEntity.getField(((EntityConditionSubSelect) value).getKeyFieldName()).getType()); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + // make sure the type of keyFieldName of EntityConditionSubSelect matches the field Java type + if (!ObjectType.instanceOf(valueType.getJavaType(), type.getJavaType())) { + String errMsg = "Warning using ["+ value.getClass().getName() + "] and entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "]. The Java type of keyFieldName : [" + valueType.getJavaType()+ "] is not compatible with the Java type of the field [" + type.getJavaType() + "]"; + // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); + Debug.logWarning(new Exception("Location of database type warning"), "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); + } + } else { // make sure the type matches the field Java type - if (!ObjectType.instanceOf(value, type.getJavaType())) { - String errMsg = "In entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "] set the value passed in [" + value.getClass().getName() + "] is not compatible with the Java type of the field [" + type.getJavaType() + "]"; - // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); - Debug.logWarning(new Exception("Location of database type warning"), "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); + if (!ObjectType.instanceOf(value, type.getJavaType())) { + String errMsg = "In entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "] set the value passed in [" + value.getClass().getName() + "] is not compatible with the Java type of the field [" + type.getJavaType() + "]"; + // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); + Debug.logWarning(new Exception("Location of database type warning"), "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); + } } } |
Free forum by Nabble | Edit this page |