Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 20056 invoked from network); 21 Aug 2007 19:58:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Aug 2007 19:58:31 -0000 Received: (qmail 4637 invoked by uid 500); 21 Aug 2007 19:58:28 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 4619 invoked by uid 500); 21 Aug 2007 19:58:28 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 4609 invoked by uid 99); 21 Aug 2007 19:58:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Aug 2007 12:58:27 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of christian.defoy@gmail.com designates 66.249.82.236 as permitted sender) Received: from [66.249.82.236] (HELO wx-out-0506.google.com) (66.249.82.236) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Aug 2007 19:58:27 +0000 Received: by wx-out-0506.google.com with SMTP id s7so1593455wxc for ; Tue, 21 Aug 2007 12:58:06 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HqlGSdYfv1LiSPJWrA1dSafXtdsWiE8JECREoNkbzZoNrybD7d2VNgQ5Q++i9/wuvwxGtfehKqPqX+auYJCQ3FiL39RYf1U48L7x0nk6Mz3lhQBuy8BNp3p/BgvLDgjTam/THMCihoxVdM9nusByGtbu6nKqnXhiVX6LWSevrlA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=hMQ5kOYK/qQMq15KfkoDvoF376I64Lrw8M2WQu+sV/ghgfOUDEREGO/sFMK6rozY9U3FV+aDYULZYzHac6OJwYHc4P7oKVmp7Js0nrjnu8wiRbq6XCcotZzkl4I/Xji5vvWwX4rrdsZ14Y3D+smYyey3Q42FBatphTzeKp2BhZQ= Received: by 10.90.63.16 with SMTP id l16mr2810162aga.1187726286569; Tue, 21 Aug 2007 12:58:06 -0700 (PDT) Received: by 10.90.52.9 with HTTP; Tue, 21 Aug 2007 12:58:06 -0700 (PDT) Message-ID: <967946b0708211258y74e88d20p973a231915da78f0@mail.gmail.com> Date: Tue, 21 Aug 2007 15:58:06 -0400 From: "Christian Defoy" To: users@openjpa.apache.org Subject: Re: Detection of constraint violations In-Reply-To: <7262f25e0708211126w6cce0772h8f1a5c17c27e35eb@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <967946b0708211119i77f17d56tece25f04be84933b@mail.gmail.com> <7262f25e0708211126w6cce0772h8f1a5c17c27e35eb@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Patrick, When I step into the code, I do see ReferentialIntegrityException being created but they get converted to PersistenceException at some point in PersistenceExceptions.translateStoreException(). My guess is that no equivalent exception exists in the JPA spec... I also only look for SQLState 23000. I have nothing special to add to that list... Thanks! Christian On 8/21/07, Patrick Linskey wrote: > When we can, we try to wrap such exceptions in a > ReferentialIntegrityException. I think that we just look for SQLState > of 23000 currently, though. > > Can you post stacks that correspond to codes that we should also be catching? > > -Patrick > > On 8/21/07, Christian Defoy wrote: > > Hello, > > > > I am looking for a way of programatically detecting whether an > > exception was caused by a constraint violation. What is the best way > > to do that? > > > > The only way I have found so far is to navigate up the cause chain of > > the exception and see if one happens to be an SQLException and if so, > > get the SQLState and see if it is 23xxx. > > > > Is there a simpler way? > > > > Oh, by the way, example 12.2 of the manual states that we can put > > @Unique annotations in the @Table one but it turns out that type must > > be @UniqueConstraint. > > > > Thanks in advance! > > > > Christian > > > > > -- > Patrick Linskey > 202 669 5907 >