Return-Path: X-Original-To: apmail-openjpa-commits-archive@www.apache.org Delivered-To: apmail-openjpa-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 61CA1CB0D for ; Mon, 24 Jun 2013 17:24:22 +0000 (UTC) Received: (qmail 86718 invoked by uid 500); 24 Jun 2013 17:24:22 -0000 Delivered-To: apmail-openjpa-commits-archive@openjpa.apache.org Received: (qmail 86637 invoked by uid 500); 24 Jun 2013 17:24:18 -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 86546 invoked by uid 99); 24 Jun 2013 17:24:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jun 2013 17:24:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Mon, 24 Jun 2013 17:24:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9FB9D2388906; Mon, 24 Jun 2013 17:23:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1496128 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java Date: Mon, 24 Jun 2013 17:23:56 -0000 To: commits@openjpa.apache.org From: allee8285@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130624172356.9FB9D2388906@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: allee8285 Date: Mon Jun 24 17:23:56 2013 New Revision: 1496128 URL: http://svn.apache.org/r1496128 Log: OPENJPA-2391 - commit patch contributed by Di Lau. Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java?rev=1496128&r1=1496127&r2=1496128&view=diff ============================================================================== --- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java (original) +++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/HSQLDictionary.java Mon Jun 24 17:23:56 2013 @@ -18,6 +18,7 @@ */ package org.apache.openjpa.jdbc.sql; +import java.lang.reflect.Field; import java.math.BigDecimal; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -27,7 +28,6 @@ import java.sql.Types; import java.util.Arrays; import org.apache.commons.lang.StringUtils; -import org.hsqldb.Trace; import org.apache.openjpa.jdbc.identifier.DBIdentifier; import org.apache.openjpa.jdbc.kernel.exps.FilterValue; import org.apache.openjpa.jdbc.schema.Column; @@ -51,6 +51,7 @@ public class HSQLDictionary extends DBDi private int dbMajorVersion; private int dbMinorVersion; + private int violation_of_unique_index_or_constraint; private SQLBuffer _oneBuffer = new SQLBuffer(this).append("1"); @@ -118,6 +119,25 @@ public class HSQLDictionary extends DBDi if (dbMajorVersion > 1 && dbMinorVersion > 0) { nextSequenceQuery += " LIMIT 1"; } + String packageName; + String fieldName; + if (dbMajorVersion > 1) { + // default value for "X_23505" + violation_of_unique_index_or_constraint = 104; + packageName = "org.hsqldb.error.ErrorCode"; + fieldName = "X_23505"; + } else { + // default value for "VIOLATION_OF_UNIQUE_INDEX" + violation_of_unique_index_or_constraint = 9; + packageName = "org.hsqldb.Trace"; + fieldName = "VIOLATION_OF_UNIQUE_INDEX"; + } + try { + Class cls = Class.forName(packageName); + Field fld = cls.getField(fieldName); + violation_of_unique_index_or_constraint = fld.getInt(null); + } catch (Exception e) { + } } /** @@ -381,7 +401,7 @@ public class HSQLDictionary extends DBDi Object failed) { OpenJPAException ke = super.newStoreException(msg, causes, failed); if (ke instanceof ReferentialIntegrityException - && causes[0].getErrorCode() == -Trace.VIOLATION_OF_UNIQUE_INDEX) { + && causes[0].getErrorCode() == -violation_of_unique_index_or_constraint) { ((ReferentialIntegrityException) ke).setIntegrityViolation (ReferentialIntegrityException.IV_UNIQUE); }