cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r902412 - /cayenne/main/trunk/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/DBHelper.java
Date Sat, 23 Jan 2010 14:48:28 GMT
Author: aadamchik
Date: Sat Jan 23 14:48:28 2010
New Revision: 902412

URL: http://svn.apache.org/viewvc?rev=902412&view=rev
Log:
CAY-1373 Make itest-common available to regular unit tests

some DB's need explicit type for null binding

Modified:
    cayenne/main/trunk/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/DBHelper.java

Modified: cayenne/main/trunk/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/DBHelper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/DBHelper.java?rev=902412&r1=902411&r2=902412&view=diff
==============================================================================
--- cayenne/main/trunk/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/DBHelper.java
(original)
+++ cayenne/main/trunk/build-tools/cayenne-test-utilities/src/main/java/org/apache/cayenne/test/DBHelper.java
Sat Jan 23 14:48:28 2010
@@ -19,6 +19,7 @@
 package org.apache.cayenne.test;
 
 import java.sql.Connection;
+import java.sql.ParameterMetaData;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -74,9 +75,22 @@
         try {
 
             PreparedStatement st = c.prepareStatement(sql.toString());
+            ParameterMetaData parameters = null;
             try {
                 for (int i = 0; i < values.length; i++) {
-                    st.setObject(i + 1, values[i]);
+
+                    if (values[i] == null) {
+
+                        // check for the right NULL type
+                        if (parameters == null) {
+                            parameters = st.getParameterMetaData();
+                        }
+
+                        st.setNull(i + 1, parameters.getParameterType(i + 1));
+                    }
+                    else {
+                        st.setObject(i + 1, values[i]);
+                    }
                 }
 
                 st.executeUpdate();



Mime
View raw message