Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 43338 invoked from network); 10 Mar 2009 16:17:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Mar 2009 16:17:09 -0000 Received: (qmail 11291 invoked by uid 500); 10 Mar 2009 16:17:08 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 11281 invoked by uid 500); 10 Mar 2009 16:17:08 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 11270 invoked by uid 99); 10 Mar 2009 16:17:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Mar 2009 09:17:08 -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: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 10 Mar 2009 16:17:02 +0000 Received: (qmail 949 invoked from network); 10 Mar 2009 16:16:39 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 10 Mar 2009 16:16:39 -0000 Message-Id: From: Andrus Adamchik To: user@cayenne.apache.org In-Reply-To: <1236697433.6175.5.camel@nikp-diaamath> Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: How can I handle validation exception? Date: Tue, 10 Mar 2009 18:16:38 +0200 References: <1236697433.6175.5.camel@nikp-diaamath> X-Mailer: Apple Mail (2.930.3) X-Virus-Checked: Checked by ClamAV on apache.org The code example looks about right. However this is probably what's =20 wrong: "When a specific condition is not met, a ValidationException is =20= thrown.". You should not throw the exception yourself. Just add an =20 error to the validationResult, and let Cayenne throw it later. Andrus On Mar 10, 2009, at 5:03 PM, =CE=9D=CE=AF=CE=BA=CE=BF=CF=82 = =CE=A0=CE=B1=CF=81=CE=AC=CF=83=CF=87=CE=BF=CF=85 wrote: > Hello, > > I implemented validateForSave(ValidationResult validationResult) in =20= > one > of my ObjEntities. When a specific condition is not met, a > ValidationException is thrown. > > How can I handle this ValidationException? > > The following doesn't work (I get: ValidationException is not thrown > anywhere inside block try{}): > > try { > mycontext.commit(); > } > catch(ValidationException vex) { > ... > } > > Thank you, > Nikos > > >