From 58bec08e999cafbde613505e8fb929af33a8748a Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Sun, 19 Feb 2006 21:21:57 +0000 Subject: [PATCH] Fixed AR-434: Ensure that persisted empty string properties are never returned as null git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2446 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/domain/PropertyValue.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/repo/domain/PropertyValue.java b/source/java/org/alfresco/repo/domain/PropertyValue.java index 695e801317..f60d4f8a33 100644 --- a/source/java/org/alfresco/repo/domain/PropertyValue.java +++ b/source/java/org/alfresco/repo/domain/PropertyValue.java @@ -45,7 +45,11 @@ public class PropertyValue implements Cloneable, Serializable { private static final long serialVersionUID = -497902497351493075L; + /** used to take care of empty strings being converted to nulls by the database */ + private static final String STRING_EMPTY = ""; + private static Log logger = LogFactory.getLog(PropertyValue.class); + private static Log loggerOracle = LogFactory.getLog(PropertyValue.class.getName() + ".oracle"); /** potential value types */ private static enum ValueType @@ -557,7 +561,21 @@ public class PropertyValue implements Cloneable, Serializable case DOUBLE: return this.doubleValue; case STRING: - return this.stringValue; + // Oracle stores empty strings as 'null'... + if (this.stringValue == null) + { + // We know that we stored a non-null string, but now it is null. + // It can only mean one thing - Oracle + if (loggerOracle.isDebugEnabled()) + { + logger.debug("string_value is 'null'. Forcing to empty String"); + } + return PropertyValue.STRING_EMPTY; + } + else + { + return this.stringValue; + } case SERIALIZABLE: return this.serializableValue; default: