openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r589784 - in /openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: kernel/TableJDBCSeq.java sql/DB2Dictionary.java sql/DBDictionary.java
Date Mon, 29 Oct 2007 18:21:57 GMT
Author: mikedd
Date: Mon Oct 29 11:21:56 2007
New Revision: 589784

URL: http://svn.apache.org/viewvc?rev=589784&view=rev
Log:
OPENJPA-399 committing Teresa's patch

Modified:
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java?rev=589784&r1=589783&r2=589784&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.java
Mon Oct 29 11:21:56 2007
@@ -235,16 +235,15 @@
                 schema = group.addSchema(schemaName);
             
             schema.importTable(_pkColumn.getTable());
-            // build the index for the sequence tables
-            // the index name will the fully qualified table name +_IDX
-            Table tab = schema.getTable(_table); 
-            Index idx = tab.addIndex(tab.getFullName()+"_IDX");
-            idx.setUnique(true);
             // we need to reset the table name in the column with the
             // fully qualified name for matching the table name from the
             // Column.
-            _pkColumn.resetTableName(schemaName+"."+_pkColumn.getTableName());
-            idx.addColumn(_pkColumn);       
+            _pkColumn.resetTableName(schemaName + "."
+                    + _pkColumn.getTableName());
+            // some databases require to create an index for the sequence table
+            _conf.getDBDictionaryInstance().createIndexIfNecessary(schema,
+                    _table, _pkColumn);
+         
         }
     }
 

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=589784&r1=589783&r2=589784&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Mon Oct 29 11:21:56 2007
@@ -31,12 +31,17 @@
 import org.apache.openjpa.jdbc.kernel.exps.Lit;
 import org.apache.openjpa.jdbc.kernel.exps.Param;
 import org.apache.openjpa.jdbc.kernel.exps.Val;
+import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.schema.Index;
+import org.apache.openjpa.jdbc.schema.Schema;
 import org.apache.openjpa.jdbc.schema.Sequence;
+import org.apache.openjpa.jdbc.schema.Table;
 import org.apache.openjpa.kernel.Filters;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.util.OpenJPAException;
 import org.apache.openjpa.util.UnsupportedException;
+
 import serp.util.Strings;
 
 /**
@@ -740,6 +745,21 @@
                 buf.replaceSqlString(sqlString.length() - 1,
                         sqlString.length(), str);
             }
+        }
+    }
+
+    /**
+     * Create an index if necessary for some database tables
+     */
+    public void createIndexIfNecessary(Schema schema, String table,
+            Column pkColumn) {
+        if (isDB2ZOSV8xOrLater()) {
+            // build the index for the sequence tables
+            // the index name will the fully qualified table name + _IDX
+            Table tab = schema.getTable(table);
+            Index idx = tab.addIndex(tab.getFullName() + "_IDX");
+            idx.setUnique(true);
+            idx.addColumn(pkColumn);
         }
     }
 }

Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=589784&r1=589783&r2=589784&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Mon Oct 29 11:21:56 2007
@@ -3982,4 +3982,11 @@
     public String getCastFunction(Val val, String func) {
         return func;
     }
+    
+    /**
+     * Create an index if necessary for some database tables
+     */
+    public void createIndexIfNecessary(Schema schema, String table,
+            Column pkColumn) {
+    }
 }



Mime
View raw message