Author: mikedd
Date: Wed Aug 11 14:33:38 2010
New Revision: 984421
URL: http://svn.apache.org/viewvc?rev=984421&view=rev
Log:
OPENJPA-1668: Allow non default sequence SQL strings for z/os and iseries.
Submitted By: Heath Thomann
Modified:
openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
openjpa/branches/1.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Modified:
openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=984421&r1=984420&r2=984421&view=diff
==============================================================================
---
openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++
openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Aug 11 14:33:38 2010
@@ -72,6 +72,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;
@@ -87,8 +90,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;
@@ -296,8 +298,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) {
@@ -315,8 +323,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/1.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL:
http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=984421&r1=984420&r2=984421&view=diff
==============================================================================
---
openjpa/branches/1.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
(original)
+++
openjpa/branches/1.2.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Wed Aug 11 14:33:38 2010
@@ -182,4 +182,12 @@ error-setting-query-timeout: A SQLExcept
continue processing. If this is a benign error you may disable it entirely
\
by setting the supportsQueryTimeout attribute on the DBDictionary to
false.\
The exception thrown was {1}.
-
\ No newline at end of file
+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.
+