Author: jonesde
Date: Sun Oct 28 23:35:19 2007 New Revision: 589517 URL: http://svn.apache.org/viewvc?rev=589517&view=rev Log: Fixed issue with new Blob on the entity level and ByteBuffer on the service level stuff related to persisting actual bytes in the db related to persisting actual bytes in the db instead of an object wrapper; also some improvements to the null value and entity, etc; the main issue here was reported by guo weizhan Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=589517&r1=589516&r2=589517&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericEntity.java Sun Oct 28 23:35:19 2007 @@ -60,7 +60,7 @@ import org.ofbiz.base.crypto.HashCrypt; /** - * Generic Entity Value Object - Handles persisntence for any defined entity. + * Generic Entity Value Object - Handles persistence for any defined entity. * <p>Note that this class extends <code>Observable</code> to achieve change notification for * <code>Observer</code>s. Whenever a field changes the name of the field will be passed to * the <code>notifyObservers()</code> method, and through that to the <code>update()</code> method of each @@ -73,7 +73,7 @@ public static final GenericEntity NULL_ENTITY = new NullGenericEntity(); public static final NullField NULL_FIELD = new NullField(); - /** Name of the GenericDelegator, used to reget the GenericDelegator when deserialized */ + /** Name of the GenericDelegator, used to re-get the GenericDelegator when deserialized */ protected String delegatorName = null; /** Reference to an instance of GenericDelegator used to do some basic operations on this entity value. If null various methods in this class will fail. This is automatically set by the GenericDelegator for all GenericValue objects instantiated through it. You may set this manually for objects you instantiate manually, but it is optional. */ @@ -1363,6 +1363,9 @@ public static class NullGenericEntity extends GenericEntity implements NULL { protected NullGenericEntity() { } + public String getEntityName() { + return "[null-entity]"; + } public String toString() { return "[null-entity]"; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java?rev=589517&r1=589516&r2=589517&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/GenericValue.java Sun Oct 28 23:35:19 2007 @@ -485,5 +485,12 @@ return newEntity; } - protected static class NullGenericValue extends GenericValue implements NULL { }; + protected static class NullGenericValue extends GenericValue implements NULL { + public String getEntityName() { + return "[null-entity-value]"; + } + public String toString() { + return "[null-entity-value]"; + } + }; } 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=589517&r1=589516&r2=589517&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 Oct 28 23:35:19 2007 @@ -24,6 +24,7 @@ import java.io.ObjectInputStream; import java.io.Reader; import java.math.BigDecimal; +import java.nio.ByteBuffer; import java.sql.Blob; import java.sql.ResultSet; import java.sql.ResultSetMetaData; @@ -773,6 +774,8 @@ case 12: if (fieldValue instanceof byte[]) { sqlP.setBytes((byte[]) fieldValue); + } else if (fieldValue instanceof ByteBuffer) { + sqlP.setBytes(((ByteBuffer) fieldValue).array()); } else { sqlP.setValue((java.sql.Blob) fieldValue); } @@ -826,9 +829,13 @@ fieldTypeMap.put("java.lang.Object", new Integer(11)); fieldTypeMap.put("Object", new Integer(11)); + fieldTypeMap.put("java.sql.Blob", new Integer(12)); fieldTypeMap.put("Blob", new Integer(12)); fieldTypeMap.put("byte[]", new Integer(12)); + fieldTypeMap.put("java.nio.ByteBuffer", new Integer(12)); + fieldTypeMap.put("java.nio.HeapByteBuffer", new Integer(12)); + fieldTypeMap.put("java.sql.Clob", new Integer(13)); fieldTypeMap.put("Clob", new Integer(13)); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java?rev=589517&r1=589516&r2=589517&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelReader.java Sun Oct 28 23:35:19 2007 @@ -437,7 +437,9 @@ } ModelEntity modelEntity = ec.get(entityName); if (modelEntity == null) { - throw new GenericModelException("Could not find definition for entity name " + entityName); + String errMsg = "Could not find definition for entity name " + entityName; + // Debug.logError(new Exception("Placeholder"), errMsg, module); + throw new GenericModelException(errMsg); } return modelEntity; } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java?rev=589517&r1=589516&r2=589517&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java Sun Oct 28 23:35:19 2007 @@ -500,6 +500,10 @@ param.fieldName = field.getName(); param.name = field.getName(); param.type = fieldType.getJavaType(); + // this is a special case where we use something different in the service layer than we do in the entity/data layer + if ("java.sql.Blob".equals(param.type)) { + param.type = "java.nio.ByteBuffer"; + } param.mode = UtilXml.checkEmpty(autoElement.getAttribute("mode")).intern(); param.optional = "true".equalsIgnoreCase(autoElement.getAttribute("optional")); // default to true param.formDisplay = !"false".equalsIgnoreCase(autoElement.getAttribute("form-display")); // default to false Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=589517&r1=589516&r2=589517&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Sun Oct 28 23:35:19 2007 @@ -1873,6 +1873,7 @@ String retVal = null; if (value != null) { + //Debug.logInfo("In DisplayEntityField.getDescription value=" + value + "; entityName=" + this.entityName, module); retVal = this.description.expandString(value, locale); } // try to get the entry for the field if description doesn't expand to anything |
Free forum by Nabble | Edit this page |