openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r658576 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: schema/SchemaTool.java sql/DBDictionary.java sql/InformixDictionary.java
Date Wed, 21 May 2008 07:42:38 GMT
Author: fancy
Date: Wed May 21 00:42:38 2008
New Revision: 658576

URL: http://svn.apache.org/viewvc?rev=658576&view=rev
Log:
OPENJPA-605 Informix will throw an exception when a unique index is explictily created on
the primary key columns
Help committing new patch provided by Fay Wang

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java?rev=658576&r1=658575&r2=658576&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
Wed May 21 00:42:38 2008
@@ -988,20 +988,9 @@
         throws SQLException {
         // Informix will automatically create a unique index for the 
         // primary key, so don't create another index again
-        if (_dict.platform.indexOf("Informix") > -1) {
-            Column[] cols = idx.getColumns();
-            Column[] pkCols = table.getPrimaryKey().getColumns();
-            if (cols.length == pkCols.length) {
-                String[] colNames = new String[cols.length];
-                String[] pkColNames = new String[cols.length];
-                for (int i = 0; i < cols.length; i++) 
-                    colNames[i] = cols[i].getName();
-                for (int i = 0; i < pkCols.length; i++) 
-                    pkColNames[i] = pkCols[i].getName();
-                if (java.util.Arrays.equals(colNames, pkColNames))
-                    return true;
-            }
-        }
+
+        if (!_dict.needsToCreateIndex(idx,table))
+            return false;
 
         int max = _dict.maxIndexesPerTable;
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=658576&r1=658575&r2=658576&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed May 21 00:42:38 2008
@@ -4407,4 +4407,8 @@
         }
         return false;
     }
+
+    public boolean needsToCreateIndex(Index idx, Table table) {
+        return true;
+    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java?rev=658576&r1=658575&r2=658576&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
Wed May 21 00:42:38 2008
@@ -268,4 +268,13 @@
             FilterValue start) {
         throw new UnsupportedException();
     }
-}
+
+    public boolean needsToCreateIndex(Index idx, Table table) {
+       // Informix will automatically create a unique index for the 
+       // primary key, so don't create another index again
+       PrimaryKey pk = table.getPrimaryKey();
+       if (pk != null && idx.columnsMatch(pk.getColumns()))
+           return false;
+       return true;
+    }
+}
\ No newline at end of file



Mime
View raw message