From 6cb121e192041b65410fa2af968921c908b14d14 Mon Sep 17 00:00:00 2001 From: "Kevin W. Sutter" Date: Fri, 29 Dec 2006 15:19:17 +0000 Subject: [PATCH] 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... git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@491027 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/sql/DB2Dictionary.java | 31 ++++++++++++++++--- .../apache/openjpa/jdbc/sql/DBDictionary.java | 3 ++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java index ecbd0f8b1..a7ae92464 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java @@ -36,6 +36,12 @@ public class DB2Dictionary 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 @@ public class DB2Dictionary 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 @@ public class DB2Dictionary 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)"; + } + } } } } diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java index 5b6ddc3a5..012672a45 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java @@ -287,6 +287,9 @@ public class DBDictionary 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;