openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fa...@apache.org
Subject svn commit: r658542 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
Date Wed, 21 May 2008 03:19:08 GMT
Author: fancy
Date: Tue May 20 20:19:08 2008
New Revision: 658542

URL: http://svn.apache.org/viewvc?rev=658542&view=rev
Log:
OPENJPA-605 Informix will throw an exception when a unique index is explictily created on
the primary key columns

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.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=658542&r1=658541&r2=658542&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
Tue May 20 20:19:08 2008
@@ -986,6 +986,23 @@
      */
     public boolean createIndex(Index idx, Table table)
         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;
+            }
+        }
+
         int max = _dict.maxIndexesPerTable;
 
         int len = table.getIndexes().length;



Mime
View raw message