Return-Path: Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: (qmail 94775 invoked from network); 21 May 2008 03:19:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 May 2008 03:19:29 -0000 Received: (qmail 98283 invoked by uid 500); 21 May 2008 03:19:30 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 98263 invoked by uid 500); 21 May 2008 03:19:30 -0000 Mailing-List: contact commits-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list commits@openjpa.apache.org Received: (qmail 98254 invoked by uid 99); 21 May 2008 03:19:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 May 2008 20:19:30 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 May 2008 03:18:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9945F23889FF; Tue, 20 May 2008 20:19:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@openjpa.apache.org From: fancy@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080521031908.9945F23889FF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;