You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2010/08/13 00:05:28 UTC
svn commit: r985013 - in /openjpa/branches/2.0.x/openjpa-jdbc/src/main:
java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
resources/org/apache/openjpa/jdbc/sql/localizer.properties
Author: mikedd
Date: Thu Aug 12 22:05:27 2010
New Revision: 985013
URL: http://svn.apache.org/viewvc?rev=985013&view=rev
Log:
OPENJPA-1668: Allow custom sequence SQL strings for DB2 on z/os and iseries.
Submitted By: Heath Thomann
Modified:
openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
openjpa/branches/2.0.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Modified: openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=985013&r1=985012&r2=985013&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original)
+++ openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Thu Aug 12 22:05:27 2010
@@ -84,6 +84,9 @@ public class DB2Dictionary
protected static final String useKeepExclusiveLockClause
= "USE AND KEEP EXCLUSIVE LOCKS";
protected static final String forReadOnlyClause = "FOR READ ONLY";
+ protected static final String defaultSequenceSQL
+ = "SELECT SEQSCHEMA AS SEQUENCE_SCHEMA, SEQNAME AS SEQUENCE_NAME FROM SYSCAT.SEQUENCES";
+
protected String databaseProductName = "";
protected String databaseProductVersion = "";
protected int maj = 0;
@@ -99,8 +102,7 @@ public class DB2Dictionary
nextSequenceQuery = "VALUES NEXTVAL FOR {0}";
- sequenceSQL = "SELECT SEQSCHEMA AS SEQUENCE_SCHEMA, "
- + "SEQNAME AS SEQUENCE_NAME FROM SYSCAT.SEQUENCES";
+ sequenceSQL = defaultSequenceSQL;
sequenceSchemaSQL = "SEQSCHEMA = ?";
sequenceNameSQL = "SEQNAME = ?";
characterColumnSize = 254;
@@ -355,8 +357,14 @@ public class DB2Dictionary
+ "SYSIBM.SYSDUMMY1";
nextSequenceQuery = "SELECT NEXTVAL FOR {0} FROM "
+ "SYSIBM.SYSDUMMY1";
- sequenceSQL = "SELECT SCHEMA AS SEQUENCE_SCHEMA, "
- + "NAME AS SEQUENCE_NAME FROM SYSIBM.SYSSEQUENCES";
+ // allow users to set a non default sequenceSQL.
+ if (defaultSequenceSQL.equals(sequenceSQL)){
+ sequenceSQL = "SELECT SCHEMA AS SEQUENCE_SCHEMA, "
+ + "NAME AS SEQUENCE_NAME FROM SYSIBM.SYSSEQUENCES";
+
+ if (log.isTraceEnabled())
+ log.trace(_loc.get("sequencesql-override", new Object[] {defaultSequenceSQL, sequenceSQL}));
+ }
sequenceSchemaSQL = "SCHEMA = ?";
sequenceNameSQL = "NAME = ?";
if (maj == 8) {
@@ -373,8 +381,14 @@ public class DB2Dictionary
+ "SYSIBM.SYSDUMMY1";
validationSQL = "SELECT DISTINCT(CURRENT TIMESTAMP) FROM "
+ "QSYS2.SYSTABLES";
- sequenceSQL = "SELECT SEQUENCE_SCHEMA, "
- + "SEQUENCE_NAME FROM QSYS2.SYSSEQUENCES";
+ // allow users to set a non default sequenceSQL.
+ if (defaultSequenceSQL.equals(sequenceSQL)){
+ sequenceSQL = "SELECT SEQUENCE_SCHEMA, "
+ + "SEQUENCE_NAME FROM QSYS2.SYSSEQUENCES";
+
+ if (log.isTraceEnabled())
+ log.trace(_loc.get("sequencesql-override", new Object[] {defaultSequenceSQL, sequenceSQL}));
+ }
sequenceSchemaSQL = "SEQUENCE_SCHEMA = ?";
sequenceNameSQL = "SEQUENCE_NAME = ?";
break;
Modified: openjpa/branches/2.0.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=985013&r1=985012&r2=985013&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties (original)
+++ openjpa/branches/2.0.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties Thu Aug 12 22:05:27 2010
@@ -208,4 +208,12 @@ can_not_get_current_schema: Unable to ge
cannot-determine-identifier-base-case: Unable to determine the case to use for \
identifiers. The default value of "{0}" will be used.
can-not-execute: Unable to execute {0}.
+sequencesql-override: Going to override the DB2 specific default for the \
+ DBDictionary.sequenceSQL string, which is: "{0}" \
+ with the value of: "{1}", which is the default sequenceSQL string for DB2 on the give operating system. \
+ If the user intends to use a value of: "{0}" by defining it as a DBDictionary property, \
+ please change the case of at least one of the charaters of the string defined in \
+ the property. This will allow openJPA to detect a difference between the DB2 default \
+ string and the string set in the property and will further allow openJPA to use the \
+ string defined by the property rather than the default string for DB2.