openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r984458 - in /openjpa/branches/1.3.x/openjpa-jdbc/src/main: java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java resources/org/apache/openjpa/jdbc/sql/localizer.properties
Date Wed, 11 Aug 2010 16:01:26 GMT
Author: mikedd
Date: Wed Aug 11 16:01:26 2010
New Revision: 984458

URL: http://svn.apache.org/viewvc?rev=984458&view=rev
Log:
OPENJPA-1668: Allow custom sequence SQL strings for z/os and iSeries with DB2. 
Submitted By: Heath Thomann

Modified:
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties

Modified: openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=984458&r1=984457&r2=984458&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Aug 11 16:01:26 2010
@@ -74,6 +74,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;
@@ -89,8 +92,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;
@@ -324,8 +326,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) {
@@ -343,8 +351,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.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?rev=984458&r1=984457&r2=984458&view=diff
==============================================================================
--- openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
(original)
+++ openjpa/branches/1.3.x/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Wed Aug 11 16:01:26 2010
@@ -198,3 +198,11 @@ dbcp-unwrap-failed: Unable to get underl
 connection-unwrap-failed: Unable to get underlying connection from pooled \
 	connection. Java version 6 and a version 4 capable JDBC driver \
 	or data source are minimum requirements to perform this operation.
+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.



Mime
View raw message