Return-Path: Delivered-To: apmail-incubator-cayenne-user-archive@locus.apache.org Received: (qmail 43254 invoked from network); 28 Apr 2006 09:52:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Apr 2006 09:52:59 -0000 Received: (qmail 13036 invoked by uid 500); 28 Apr 2006 09:52:54 -0000 Delivered-To: apmail-incubator-cayenne-user-archive@incubator.apache.org Received: (qmail 13019 invoked by uid 500); 28 Apr 2006 09:52:54 -0000 Mailing-List: contact cayenne-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-user@incubator.apache.org Delivered-To: mailing list cayenne-user@incubator.apache.org Received: (qmail 12998 invoked by uid 99); 28 Apr 2006 09:52:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Apr 2006 02:52:53 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [211.29.132.197] (HELO mail16.syd.optusnet.com.au) (211.29.132.197) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Apr 2006 02:52:52 -0700 Received: from Fanscom (c211-30-101-18.carlnfd1.nsw.optusnet.com.au [211.30.101.18]) by mail16.syd.optusnet.com.au (8.12.11/8.12.11) with ESMTP id k3S9qKBZ019167 for ; Fri, 28 Apr 2006 19:52:29 +1000 From: "Bill Fan" To: Subject: RE: How to enforce Delete before Insert? Date: Fri, 28 Apr 2006 19:52:21 +1000 Message-ID: <000a01c66aa9$753ff1a0$0300a8c0@Fanscom> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <272890087@web.de> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks Juergen! Can you still manage the db traction when you do delete = and insert in separate context? I can force it to do the DELETE first if I execute commitChanges() after = the deleteObjects statement...however, this could be potentially dangerous = as what I'm trying to do here should be in a atomic db transaction.=20 I guess I have to do it in the hard way, analyze the changes and do = INSERT and DELETE accordingly. Cheers. -----Original Message----- From: J=FCrgen Saar [mailto:Juergen@JSaar.org]=20 Sent: Friday, 28 April 2006 5:40 PM To: cayenne-user@incubator.apache.org Subject: Re: How to enforce Delete before Insert? This problem is well known to me.=20 We do it the same way.=20 It is much easyier because it is not neccessary to analyze for changes. Cayenne does not commit the changes in a fifo-logic. To solve this we use a separate context for delete and insert ... --- Juergen --- -----Urspr=FCngliche Nachricht----- Hi, I have a Product & a ProductRelation tables. When the ProductRelation records for a product are managed in a web page, I'd like to delete the exiting records in the ProductRelation table for this product first, = then insert the new one. I'm having trouble to do this with the following code. I got the "Cannot insert duplicate key in object ..." db error. The reason appears that = the DELET statements appear after the INSERT statements from what I can see = in the QueryLogger output. Could someone please help? I'm using Cayenne = 1.2B2. The code: =3D=3D=3D=3D=3D=3D=3D=3D=3D public void saveProductRelation(Product product, String relatedProductId[], Type relationType) { // delete the existing records =20 log.debug("product.getProductRelationArray().size()=3D" + product.getProductRelationArray().size()); threadDataContext().deleteObjects(product.getProductRelationArray()); if (relatedProductId.length > 0) { for (int i=3D0; i cayenne.access.QueryLogger.logQueryStart (QueryLogger.java:459) - <--- will run 2 queries.> cayenne.access.QueryLogger.logBeginTransaction(QueryLogger.java:413) - = <--- transaction started.> cayenne.access.QueryLogger.logQuery(QueryLogger.java :336) - cayenne.access.QueryLogger.logQueryParameters(QueryLogger.java:358) - <[bind: 242, 9, 16]> cayenne.access.QueryLogger.logUpdateCount (QueryLogger.java:404) - <=3D=3D=3D updated 1 row.> cayenne.access.QueryLogger.logQuery(QueryLogger.java:336) - cayenne.access.QueryLogger.logQueryParameters(QueryLogger.java:358) - <[bind: 242, 222, 16]> Many thanks in advace! Bill =09 =09 =09 =09 =09 =09 =09
3D""
3D""
Anlage zu dieser E-Mail hinzuf=FCgen
3D""
3D"" 1. Schritt: Datei ausw=E4hlen 3D"" 3D""
3D""
3D"" 2. Schritt: Datei hochladen 3D"" 3D"" Komfort-Upload 3D""
3D""
Tipp: = Anlagen bis 50 MB verschicken
=20
= Empf=E4nger per SMS auf diese Nachricht hinweisen 3D""
= Empf=E4nger per SMS auf diese Nachricht hinweisen 3D""
3D""
Handy-Nummer: = Tarife & Club-Rabatte =
3D""
Sicherheit 3D""
Sicherheit 3D""
3D""
Digitale Unterschrift: =09 diese Nachricht mit meinem Zertifikat digital unterschreiben 3D""
Verschl=FCsselung: =09 =09 diese Nachricht verschl=FCsseln=20 =09 =09 =09 =09 Sicherheit bei WEB.DE
=09
3D""
= Meine Visitenkarte 3D""
= Meine Visitenkarte 3D""
3D""
=09 =20 =09 =09
3D"" 3D"" 3D"" 3D"" Meine Visitenkarte anh=E4ngen 3D""
3D""
=09 =09 =09
=09
=09
=09
=09 =09 =09
3D""
Impressum - WEB.DE GmbH - Presse - Werbung - Jobs

_______________________________________________________________ SMS schreiben mit WEB.DE FreeMail - einfach, schnell und kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=3D021192