[OFBiz] SVN: r6095 - in trunk/framework/entity/src/org/ofbiz/entity: condition datasource finder jdbc model

jonesde at svn.ofbiz.org jonesde at svn.ofbiz.org
Tue Nov 8 20:39:09 EST 2005


Author: jonesde
Date: 2005-11-08 19:38:54 -0600 (Tue, 08 Nov 2005)
New Revision: 6095

Modified:
   trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java
   trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
   trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java
   trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
   trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java
   trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
   trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
Log:
Fixed method in ModelEntity.convertFieldValue to not break the GenericEntity.NULL_FIELD stuff, ie convert it to a String when the field java type is String

Modified: trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/condition/EntityComparisonOperator.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -92,6 +92,7 @@
     }
 
     public void addSqlValue(StringBuffer sql, ModelEntity entity, List entityConditionParams, boolean compat, Object lhs, Object rhs) {
+        //Debug.logInfo("EntityComparisonOperator.addSqlValue field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module);
         ModelField field;
         if (lhs instanceof EntityConditionValue) {
             EntityConditionValue ecv = (EntityConditionValue) lhs;
@@ -108,6 +109,7 @@
             addValue(sql, null, lhs, entityConditionParams);
             field = null;
         }
+
         makeRHSWhereString(entity, entityConditionParams, sql, field, rhs);
     }
 

Modified: trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -31,6 +31,7 @@
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.entity.EntityCryptoException;
 import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.model.ModelField;
@@ -62,7 +63,7 @@
             throw new IllegalArgumentException("The operator argument cannot be null");
         }
 
-        if (rhs == null) {
+        if (rhs == null || rhs == GenericEntity.NULL_FIELD) {
             if (!EntityOperator.NOT_EQUAL.equals(operator) && !EntityOperator.EQUALS.equals(operator)) {
                 throw new IllegalArgumentException("Operator must be EQUALS or NOT_EQUAL when right/rhs argument is NULL ");
             }
@@ -77,10 +78,13 @@
         this.lhs = lhs;
         this.operator = operator;
         this.rhs = rhs;
+
+        //Debug.logInfo("new EntityExpr internal field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module);
     }
 
     public EntityExpr(String lhs, EntityComparisonOperator operator, Object rhs) {
         this(new EntityFieldValue(lhs), operator, rhs);
+        //Debug.logInfo("new EntityExpr field=" + lhs + ", value=" + rhs + ", value type=" + (rhs == null ? "null object" : rhs.getClass().getName()), module);
     }
 
     public EntityExpr(String lhs, boolean leftUpper, EntityComparisonOperator operator, Object rhs, boolean rightUpper) {

Modified: trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/condition/EntityOperator.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- *  Copyright (c) 2002-2004 The Open For Business Project - www.ofbiz.org
+ *  Copyright (c) 2002-2005 The Open For Business Project - www.ofbiz.org
  *
  *  Permission is hereby granted, free of charge, to any person obtaining a
  *  copy of this software and associated documentation files (the "Software"),
@@ -30,6 +30,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntity;
 import org.ofbiz.entity.GenericModelException;
@@ -90,8 +91,10 @@
         public boolean compare(Object lhs, Object rhs) { return EntityComparisonOperator.compareEqual(lhs, rhs); }
         protected void makeRHSWhereString(ModelEntity entity, List entityConditionParams, StringBuffer sb, ModelField field, Object rhs) {
             if (rhs == null || rhs == GenericEntity.NULL_FIELD) {
+                //Debug.logInfo("makeRHSWhereString: field IS NULL: " + field.getName(), module);
                 sb.append(" IS NULL");
             } else {
+                //Debug.logInfo("makeRHSWhereString: field not null, doing super: " + field.getName() + ", type: " + rhs.getClass().getName() + ", value: " + rhs, module);
                 super.makeRHSWhereString(entity, entityConditionParams, sb, field, rhs);
             }
         }
@@ -170,10 +173,11 @@
     }
 
     public String getCode() {
-        if (codeString == null)
+        if (codeString == null) {
             return "null";
-        else
+        } else {
             return codeString;
+        }
     }
 
     public int getId() {

Modified: trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -792,7 +792,7 @@
         if (Debug.timingOn()) {
             long queryEndTime = System.currentTimeMillis();
             long queryTotalTime = queryEndTime - queryStartTime;
-            if (queryTotalTime > 100) {
+            if (queryTotalTime > 10) {
                 Debug.logTiming("Ran query in " + queryTotalTime + " milli-seconds: " + sql, module);
             }
         }        

Modified: trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/finder/ByConditionFinder.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- *  Copyright (c) 2004 The Open For Business Project - www.ofbiz.org
+ *  Copyright (c) 2004-2005 The Open For Business Project - www.ofbiz.org
  *
  *  Permission is hereby granted, free of charge, to any person obtaining a
  *  copy of this software and associated documentation files (the "Software"),

Modified: trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -261,7 +261,7 @@
             }
 
             Object fieldValue = fields.get(name);
-            if (fieldValue != null) {
+            if (fieldValue != null && fieldValue != GenericEntity.NULL_FIELD) {
                 returnString.append('=');
                 addValue(returnString, modelField, fieldValue, entityConditionParams);
             } else {

Modified: trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java
===================================================================
--- trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java	2005-11-09 01:25:32 UTC (rev 6094)
+++ trunk/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java	2005-11-09 01:38:54 UTC (rev 6095)
@@ -1132,6 +1132,9 @@
     }
     
     public Object convertFieldValue(ModelField modelField, Object value, GenericDelegator delegator) {
+        if (value == null || value == GenericEntity.NULL_FIELD) {
+            return null;
+        }
         String fieldJavaType = null;
         try {
             fieldJavaType = delegator.getEntityFieldType(this, modelField.getType()).getJavaType();



More information about the Svn mailing list