Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 10460 invoked from network); 15 Jul 2008 20:32:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jul 2008 20:32:43 -0000 Received: (qmail 37843 invoked by uid 500); 15 Jul 2008 20:32:42 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 37837 invoked by uid 500); 15 Jul 2008 20:32:42 -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 Delivered-To: moderator for user@cayenne.apache.org Received: (qmail 95176 invoked by uid 99); 15 Jul 2008 19:49:33 -0000 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of devyandu@gmail.com designates 64.233.184.228 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=JpKBYqTini+bNnKhrm92LtvgxDtv7D9wd67jeaUXNoE=; b=MrEAqv8kxy78VevcaUtIAHs0/qGBFk2EM1JR70kqpC3FaHt/hrroeZMPAaiKKay9Yj kDnedEVMivGE8vKTCBST5gxp5YjSMIR9bTPHpaote8t4MWCQDEi/HXs00/18lLl5epzT ar8ehJAgliJaKiny66SpqxB4IfPCTcoPfm9hM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=x2r/y3rzjvj6sfgNF8vsrIM4kol3FHahFROvXdJjWkQyZzFrb4e/HkPyVq0rC3UHGF AJ12Rq8C2Lag4aB0I8cKNZ5KppNEaHNKnOa/De8+G0XncPRVpOdqEW61WmCYgPRtIp5T KjejVT8lpTtFj227dwpgR6L920HpCIwSzx5Pg= Message-ID: Date: Tue, 15 Jul 2008 15:49:03 -0400 From: Devyandu To: user@cayenne.apache.org Subject: What to do with new objects if validation fails on Commit MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_14342_3579133.1216151343415" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_14342_3579133.1216151343415 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I am new to Cayenne but enjoying using it, I have a question about what to do with new or modified objects when a validation failure or runtime exception happens on Commit. This is my Environment TomCat 5.0 Java 1.4.2 Cayenne 2.0.4 Struts For example in my save new painting Actionclass DataContext context=context.getgetThreadDataContext(); //Get artist object Artist a= (Artist)DataObjectUtils.objectForPK(context,State.class, 1); Painting p = (Painting)context.newObject(Painting.class); //Fill in painting from Form post (I use Dozer) . . p.setToArtist(a); try { context.commit(); } catch (Exception e) { //What to do here ??? } What do I do when there is an exception, (unregisterobjects?) I do not want the modified Artist and the new Painting sitting on the context. Because Cayenne would try to commit them if the user went to the gallery screen now and changed a Gallery. Should I not use the threadDataContext in a web app and create a new data context for each save page to avoid this problem. What is the convention for a web/struts app. I am sure many people have encountered and solved this before me. Thanks in advance, DB ------=_Part_14342_3579133.1216151343415--