You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jr...@apache.org on 2010/12/16 21:09:08 UTC

svn commit: r1050137 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java

Author: jrbauer
Date: Thu Dec 16 20:09:08 2010
New Revision: 1050137

URL: http://svn.apache.org/viewvc?rev=1050137&view=rev
Log:
OPENJPA-1907 Use java.util.Date to java.sql.Date type mapping with DB2 on z/OS when column information is not available.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=1050137&r1=1050136&r2=1050137&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Thu Dec 16 20:09:08 2010
@@ -31,6 +31,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.StringTokenizer;
 
 import org.apache.openjpa.jdbc.identifier.DBIdentifier;
@@ -1100,4 +1101,20 @@ public class DB2Dictionary
         throws SQLException {
         //NO-OP
     }
+    
+    /**
+     * Set the given date value as a parameter to the statement.
+     */
+    public void setDate(PreparedStatement stmnt, int idx, Date val, Column col)
+        throws SQLException {
+        // When column metadata is not available, DB2 on z/OS does not like the value produced
+        // by the default dictionary - java.util.Date is converted to java.sql.Timestamp.
+        if (db2ServerType == db2ZOSV8xOrLater) {
+            if (col == null && val != null && "java.util.Date".equals(val.getClass().getName())) {
+                setDate(stmnt, idx, new java.sql.Date(val.getTime()), null, col);
+                return;
+            }
+        }
+        super.setDate(stmnt, idx, val, col);
+    }
 }