You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2011/12/22 15:16:07 UTC
svn commit: r1222242 -
/ofbiz/branches/release09.04/framework/entity/src/org/ofbiz/entity/GenericEntity.java
Author: jleroux
Date: Thu Dec 22 14:16:07 2011
New Revision: 1222242
URL: http://svn.apache.org/viewvc?rev=1222242&view=rev
Log:
A modified patch from Patrick Antivackis "Null values are not synchronized in http mode" https://issues.apache.org/jira/browse/OFBIZ-4602
In order to send over http the values to create, store and remove, Ofbiz is Xml serializing the values. GenericValue xml serialization is managed in GenericEntity.makeXmlElement, unfortunately this method just don't serialized null valued fields.
To solve this issue, I managed null value the same way GenericEntity.setString (which is used for the Xml deserializing). I only managed until case 10, because i'm not sure the setString for the cases 11 to 15 are well managed (not taking care of null value)
jleroux: After looking at GenericEntity.setString and initial commit (http://svn.ofbiz.org/viewcvs?rev=7779&view=rev) I see no reasons to not handling cases under 10 the same way. So I added these cases as well using fall through.
Modified:
ofbiz/branches/release09.04/framework/entity/src/org/ofbiz/entity/GenericEntity.java
Modified: ofbiz/branches/release09.04/framework/entity/src/org/ofbiz/entity/GenericEntity.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/framework/entity/src/org/ofbiz/entity/GenericEntity.java?rev=1222242&r1=1222241&r2=1222242&view=diff
==============================================================================
--- ofbiz/branches/release09.04/framework/entity/src/org/ofbiz/entity/GenericEntity.java (original)
+++ ofbiz/branches/release09.04/framework/entity/src/org/ofbiz/entity/GenericEntity.java Thu Dec 22 14:16:07 2011
@@ -988,6 +988,42 @@ public class GenericEntity extends Obser
element.setAttribute(name, value);
}
}
+ else {
+ ModelFieldType type = null;
+ try {
+ type = getDelegator().getEntityFieldType(getModelEntity(), modelField.getType());
+ } catch (GenericEntityException e) {
+ Debug.logWarning(e, module);
+ }
+ if (type == null) throw new IllegalArgumentException("Type " + modelField.getType() + " not found");
+ String fieldType = type.getJavaType();
+
+ try {
+ switch (SqlJdbcUtil.getType(fieldType)) {
+ case 1: // String
+ set(name, "");
+ break;
+ case 2: // Timestamp
+ case 3: // Time
+ case 4: // java.sql.Date
+ case 5: // Integer
+ case 6: // Long
+ case 7: // Float
+ case 8: // Double
+ case 9: // BigDecimal
+ case 10:// Boolean
+ case 11:// Object
+ case 12:// Blob, byte[], ByteBuffer, HeapByteBuffer
+ case 13:// Clob
+ case 14:// java.util.Date
+ case 15:// Collection: ArrayList, HashSet, LinkedHashSet, LinkedList
+ element.setAttribute(name, "null");
+ break;
+ }
+ } catch (GenericNotImplementedException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+ }
}
return element;