openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwsut...@apache.org
Subject svn commit: r491027 - in /incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java
Date Fri, 29 Dec 2006 15:19:18 GMT
Author: kwsutter
Date: Fri Dec 29 07:19:17 2006
New Revision: 491027

URL: http://svn.apache.org/viewvc?view=rev&rev=491027
Log:
Changes for JIRA OPENJPA-77 issue.

These changes allow the use of the DB2Dictionary with DB2 on z/OS.  May need more in the future,
but these will get us started...

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

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=491027&r1=491026&r2=491027
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Fri Dec 29 07:19:17 2006
@@ -36,6 +36,12 @@
 
         nextSequenceQuery = "VALUES NEXTVAL FOR {0}";
 
+        sequenceSQL = "SELECT SEQSCHEMA AS SEQUENCE_SCHEMA, "
+            + "SEQNAME AS SEQUENCE_NAME FROM SYSCAT.SEQUENCES";
+        sequenceSchemaSQL = "SEQSCHEMA = ?";
+        sequenceNameSQL = "SEQNAME = ?";
+        characterColumnSize = 254;
+
         binaryTypeName = "BLOB(1M)";
         longVarbinaryTypeName = "BLOB(1M)";
         varbinaryTypeName = "BLOB(1M)";
@@ -112,17 +118,16 @@
 
     protected String getSequencesSQL(String schemaName, String sequenceName) {
         StringBuffer buf = new StringBuffer();
-        buf.append("SELECT SEQSCHEMA AS SEQUENCE_SCHEMA, ").
-            append("SEQNAME AS SEQUENCE_NAME FROM SYSCAT.SEQUENCES");
+        buf.append(sequenceSQL);
         if (schemaName != null || sequenceName != null)
             buf.append(" WHERE ");
         if (schemaName != null) {
-            buf.append("SEQSCHEMA = ?");
+            buf.append(sequenceSchemaSQL);
             if (sequenceName != null)
                 buf.append(" AND ");
         }
         if (sequenceName != null)
-            buf.append("SEQNAME = ?");
+            buf.append(sequenceNameSQL);
         return buf.toString();
     }
 
@@ -157,6 +162,24 @@
 	    		supportsLockingWithOuterJoin = true;
 	    		forUpdateClause = "WITH RR USE AND KEEP UPDATE LOCKS";
 	    	}
+
+            if (metaData.getDatabaseProductVersion().indexOf("DSN") != -1) {
+                // DB2 Z/OS
+                characterColumnSize = 255;
+                lastGeneratedKeyQuery = "SELECT IDENTITY_VAL_LOCAL() FROM "
+                    + "SYSIBM.SYSDUMMY1";
+                nextSequenceQuery = "SELECT NEXTVAL FOR {0} FROM "
+                    + "SYSIBM.SYSDUMMY1";
+                sequenceSQL = "SELECT SCHEMA AS SEQUENCE_SCHEMA, "
+                    + "NAME AS SEQUENCE_NAME FROM SYSIBM.SYSSEQUENCES";
+                sequenceSchemaSQL = "SCHEMA = ?";
+                sequenceNameSQL = "NAME = ?";
+                if (maj == 8) {
+                    // DB2 Z/OS Version 8: no bigint support, hence map Java
+                    // long to decimal
+                    bigintTypeName = "DECIMAL(31,0)";
+                }
+            }
     	}
     }
 }

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=491027&r1=491026&r2=491027
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Fri Dec 29 07:19:17 2006
@@ -287,6 +287,9 @@
     public boolean supportsAutoAssign = false;
     public String lastGeneratedKeyQuery = null;
     public String nextSequenceQuery = null;
+    public String sequenceSQL = null;
+    public String sequenceSchemaSQL = null;
+    public String sequenceNameSQL = null;
 
     protected JDBCConfiguration conf = null;
     protected Log log = null;



Mime
View raw message