summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2008-11-26 06:05:33 (EST)
committerStefan Winkler2008-11-26 06:05:33 (EST)
commit741d7af7f58b79f0fcf20c2397e604594f5e139a (patch)
tree6add93361a59fffecb84f76ed27b89ba1b66bf3f
parent51f41266603256adb255159b48afd384203cfa5c (diff)
downloadcdo-741d7af7f58b79f0fcf20c2397e604594f5e139a.zip
cdo-741d7af7f58b79f0fcf20c2397e604594f5e139a.tar.gz
cdo-741d7af7f58b79f0fcf20c2397e604594f5e139a.tar.bz2
[256462] [DB] preparedStatement problem during commit
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256462
-rw-r--r--features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/PreparedStatementJDBCDelegate.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DBStoreTest.java37
4 files changed, 52 insertions, 5 deletions
diff --git a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
index 209ae18..3511572 100644
--- a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
+++ b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
@@ -21,10 +21,9 @@
<property name="toOneReferences" value="LIKE_ATTRIBUTES"/>
</mappingStrategy>
- <jdbcDelegate type="statement" />
<!-- Old setting <jdbcDelegate type="statement" />
- is now replaced by preparedStatement:
- <jdbcDelegate type="preparedStatement" > -->
+ is now replaced by preparedStatement: -->
+ <jdbcDelegate type="preparedStatement" >
<!-- to explicitly force prepared statement caching (e.g., if statement pooling is not supported
by the JDBC driver, use
<property name="cacheStatements" value="enabled" />
@@ -33,7 +32,7 @@
Which guesses the correct setting based on the JDBC driver's metadata.
Also supported is the third setting "disabled".
-->
- <!-- </jdbcDelegate> -->
+ </jdbcDelegate>
<dbAdapter name="derby-embedded"/>
<dataSource class="org.apache.derby.jdbc.EmbeddedDataSource"
databaseName="/temp/cdodb1"
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/PreparedStatementJDBCDelegate.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/PreparedStatementJDBCDelegate.java
index 3b4d345..a37a50e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/PreparedStatementJDBCDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/jdbc/PreparedStatementJDBCDelegate.java
@@ -235,7 +235,15 @@ public class PreparedStatementJDBCDelegate extends AbstractJDBCDelegate
for (IAttributeMapping attributeMapping : attributeMappings)
{
Object value = attributeMapping.getRevisionValue(revision);
- stmt.setObject(col++, value);
+
+ if (value == null)
+ {
+ stmt.setNull(col++, attributeMapping.getField().getType().getCode());
+ }
+ else
+ {
+ stmt.setObject(col++, value);
+ }
}
stmt.execute();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
index 161a291..eee5125 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java
@@ -82,6 +82,9 @@ public abstract class AllTestsAllConfigs extends ConfigTestSuite
// Specific for MEMStore
testClasses.add(MEMStoreQueryTest.class);
+ // Specific for DBStore
+ testClasses.add(DBStoreTest.class);
+
// Bugzilla verifications
testClasses.add(Bugzilla_241464_Test.class);
testClasses.add(Bugzilla_243310_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DBStoreTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DBStoreTest.java
new file mode 100644
index 0000000..98e782b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DBStoreTest.java
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Winkler - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.tests;
+
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.model1.Company;
+import org.eclipse.emf.cdo.tests.model1.Model1Factory;
+
+/**
+ * @author Stefan Winkler
+ */
+public class DBStoreTest extends AbstractCDOTest
+{
+ // Bug 256462
+ public void testInsertNull() throws Exception
+ {
+ CDOSession s = openModel1Session();
+ CDOTransaction t = s.openTransaction();
+ CDOResource r = t.createResource("/dbStoreTest");
+
+ Company c = Model1Factory.eINSTANCE.createCompany();
+ c.setName(null);
+ r.getContents().add(c);
+
+ t.commit();
+ }
+}