Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2012-11-28 13:39:52 +0000
committerMartin Taal2012-11-28 13:39:52 +0000
commitc0e41547cfc2160e2cf3b81f9c098afa5b3e19e9 (patch)
treeb1178e235b56a0d35dec74c88d8f61ea90e7c6e5 /plugins/org.eclipse.emf.cdo.server.hibernate/src
parent2af8d6076cfce132042ef3055e2ed59107d5c728 (diff)
downloadcdo-c0e41547cfc2160e2cf3b81f9c098afa5b3e19e9.tar.gz
cdo-c0e41547cfc2160e2cf3b81f9c098afa5b3e19e9.tar.xz
cdo-c0e41547cfc2160e2cf3b81f9c098afa5b3e19e9.zip
Related to issue [387752] - [Hibernate] EMF Default values are not persisted
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java
index 1af79b6c63..e9862fdf22 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/tuplizer/CDOPropertySetter.java
@@ -81,6 +81,8 @@ public class CDOPropertySetter extends CDOPropertyHandler implements Setter
{
InternalCDORevision revision = (InternalCDORevision)target;
+ final Object defaultValue = getEStructuralFeature().getDefaultValue();
+
// handle a special case: the byte array.
// hibernate will pass a Byte[] while CDO wants a byte[] (object vs. primitive array)
final Object newValue;
@@ -108,7 +110,6 @@ public class CDOPropertySetter extends CDOPropertyHandler implements Setter
}
else if (value == null)
{
- final Object defaultValue = getEStructuralFeature().getDefaultValue();
if (defaultValue == null)
{
newValue = null;
@@ -143,7 +144,10 @@ public class CDOPropertySetter extends CDOPropertyHandler implements Setter
final boolean notChanged = currentValue == CDORevisionData.NIL && newValue == null || currentValue == newValue
|| isEenumDefaultValue(value) || currentValue != null && newValue != null && currentValue.equals(newValue);
final boolean hasChanged = !notChanged;
- if (hasChanged)
+ // hibernate stores the default value, CDO maintains it as null
+ final boolean defaultValueSet = !handleUnsetAsNull && currentValue == null && defaultValue != null
+ && newValue != null && newValue.equals(defaultValue);
+ if (!defaultValueSet && hasChanged)
{
revision.setValue(getEStructuralFeature(), newValue);
}

Back to the top