diff options
3 files changed, 25 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java index 5d4b3024d6..9a5978ec07 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java @@ -34,6 +34,8 @@ import org.eclipse.net4j.db.ddl.IDBField; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.util.om.trace.ContextTracer; +import org.eclipse.emf.common.util.Enumerator; +import org.eclipse.emf.ecore.EEnum; import org.eclipse.emf.ecore.EEnumLiteral; import org.eclipse.emf.ecore.EStructuralFeature; @@ -96,7 +98,7 @@ public abstract class TypeMapping implements ITypeMapping public void setDefaultValue(PreparedStatement stmt, int index) throws SQLException { - setValue(stmt, index, feature.getDefaultValue()); + setValue(stmt, index, getDefaultValue()); } public final void setValue(PreparedStatement stmt, int index, Object value) throws SQLException @@ -112,7 +114,7 @@ public abstract class TypeMapping implements ITypeMapping } else if (value == null) { - if (feature.isMany() || feature.getDefaultValue() == null) + if (feature.isMany() || getDefaultValue() == null) { if (TRACER.isEnabled()) { @@ -181,7 +183,7 @@ public abstract class TypeMapping implements ITypeMapping } else { - if (feature.getDefaultValue() == null) + if (getDefaultValue() == null) { if (TRACER.isEnabled()) { @@ -206,6 +208,11 @@ public abstract class TypeMapping implements ITypeMapping return value; } + protected Object getDefaultValue() + { + return feature.getDefaultValue(); + } + protected final Object getRevisionValue(InternalCDORevision revision) { return revision.getValue(getFeature()); @@ -276,16 +283,19 @@ public abstract class TypeMapping implements ITypeMapping } @Override - public void setDefaultValue(PreparedStatement stmt, int index) throws SQLException + protected Object getDefaultValue() { - EEnumLiteral defaultValue = (EEnumLiteral)getFeature().getDefaultValue(); - setValue(stmt, index, defaultValue.getValue()); - } + EEnum eenum = (EEnum)getFeature().getEType(); - @Override - protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException - { - super.doSetValue(stmt, index, value); + String defaultValueLiteral = getFeature().getDefaultValueLiteral(); + if (defaultValueLiteral != null) + { + EEnumLiteral literal = eenum.getEEnumLiteralByLiteral(defaultValueLiteral); + return literal.getValue(); + } + + Enumerator enumerator = (Enumerator)eenum.getDefaultValue(); + return enumerator.getValue(); } } diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java index 49fbddc579..fb46266072 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java +++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.server.db.CDODBUtil; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.tests.BranchingTest; import org.eclipse.emf.cdo.tests.BranchingTestSameSession; +import org.eclipse.emf.cdo.tests.MergingTest; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import org.eclipse.net4j.db.DBUtil; @@ -60,6 +61,7 @@ public class AllTestsDBH2Branching extends DBConfigs // add branching tests for this testsuite testClasses.add(BranchingTest.class); testClasses.add(BranchingTestSameSession.class); + testClasses.add(MergingTest.class); super.initTestClasses(testClasses); } diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java index ed02bd57e7..50c2ad9857 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java +++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java @@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.tests.BranchingTest; import org.eclipse.emf.cdo.tests.BranchingTestSameSession; import org.eclipse.emf.cdo.tests.ExternalReferenceTest; import org.eclipse.emf.cdo.tests.FeatureMapTest; +import org.eclipse.emf.cdo.tests.MergingTest; import org.eclipse.emf.cdo.tests.XATransactionTest; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_259869_Test; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; @@ -36,6 +37,7 @@ public abstract class DBConfigs extends AllTestsAllConfigs // Subclasses should add Banching tests if supported testClasses.remove(BranchingTest.class); testClasses.remove(BranchingTestSameSession.class); + testClasses.remove(MergingTest.class); testClasses.add(DBStoreTest.class); testClasses.add(SQLQueryTest.class); |