mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user