summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2009-05-08 10:08:39 (EDT)
committerStefan Winkler2009-05-08 10:08:39 (EDT)
commit4911cd6c200f616b7b663b08ec33806adcf3e71a (patch)
treeb6db8357d25ac76fbfb255717516c8b6edd426ba
parente457daecbcbbe98016595346fbe7fb555521e7e0 (diff)
downloadcdo-4911cd6c200f616b7b663b08ec33806adcf3e71a.zip
cdo-4911cd6c200f616b7b663b08ec33806adcf3e71a.tar.gz
cdo-4911cd6c200f616b7b663b08ec33806adcf3e71a.tar.bz2
[275303] [DB] DBStore does not handle BIG_INTEGER and BIG_DECIMAL
https://bugs.eclipse.org/bugs/show_bug.cgi?id=275303
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/TypeMapping.java49
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Hsqldb - nonaudit).launch4
3 files changed, 59 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
index 7b909df..3082ef9 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java
@@ -435,6 +435,14 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp
{
return new TypeMapping.TMString(this, feature);
}
+ else if (type == CDOType.BIG_INTEGER)
+ {
+ return new TypeMapping.TMBigInteger(this, feature);
+ }
+ else if (type == CDOType.BIG_DECIMAL)
+ {
+ return new TypeMapping.TMBigDecimal(this, feature);
+ }
else if (type == CDOType.BYTE_ARRAY)
{
return new TypeMapping.TMBytes(this, feature);
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 7cdcfe3..a7d6e46 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
@@ -8,6 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
* Stefan Winkler - 271444: [DB] Multiple refactorings https://bugs.eclipse.org/bugs/show_bug.cgi?id=271444
+ * Stefan Winkler - 275303: [DB] DBStore does not handle BIG_INTEGER and BIG_DECIMAL
*/
package org.eclipse.emf.cdo.server.internal.db.mapping;
@@ -25,6 +26,8 @@ import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.emf.ecore.EStructuralFeature;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -407,4 +410,50 @@ public abstract class TypeMapping implements ITypeMapping
return resultSet.getBoolean(column);
}
}
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class TMBigInteger extends TypeMapping
+ {
+ public TMBigInteger(IMappingStrategy strategy, EStructuralFeature feature)
+ {
+ super(strategy, feature);
+ }
+
+ @Override
+ protected Object getResultSetValue(ResultSet resultSet, int column) throws SQLException
+ {
+ return new BigInteger(resultSet.getString(column));
+ }
+
+ @Override
+ protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
+ {
+ stmt.setString(index, ((BigInteger)value).toString());
+ }
+ }
+
+ /**
+ * @author Stefan Winkler
+ */
+ public static class TMBigDecimal extends TypeMapping
+ {
+ public TMBigDecimal(IMappingStrategy strategy, EStructuralFeature feature)
+ {
+ super(strategy, feature);
+ }
+
+ @Override
+ protected Object getResultSetValue(ResultSet resultSet, int column) throws SQLException
+ {
+ return new BigDecimal(resultSet.getString(column));
+ }
+
+ @Override
+ protected void doSetValue(PreparedStatement stmt, int index, Object value) throws SQLException
+ {
+ stmt.setString(index, ((BigDecimal)value).toPlainString());
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Hsqldb - nonaudit).launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Hsqldb - nonaudit).launch
index 57acfcd..4882695 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Hsqldb - nonaudit).launch
+++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (Hsqldb - nonaudit).launch
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/AllTestsDBHsqldbPrepStmtNonAudit.java"/>
+<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
@@ -14,7 +14,7 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBHsqldbPrepStmtNonAudit"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBHsqldbNonAudit"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx512m"/>
</launchConfiguration>