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
This commit is contained in:
Derek Hulley
2006-02-19 21:21:57 +00:00
parent b3c0377af7
commit 58bec08e99

View File

@@ -45,7 +45,11 @@ public class PropertyValue implements Cloneable, Serializable
{ {
private static final long serialVersionUID = -497902497351493075L; 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 logger = LogFactory.getLog(PropertyValue.class);
private static Log loggerOracle = LogFactory.getLog(PropertyValue.class.getName() + ".oracle");
/** potential value types */ /** potential value types */
private static enum ValueType private static enum ValueType
@@ -557,7 +561,21 @@ public class PropertyValue implements Cloneable, Serializable
case DOUBLE: case DOUBLE:
return this.doubleValue; return this.doubleValue;
case STRING: 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: case SERIALIZABLE:
return this.serializableValue; return this.serializableValue;
default: default: