Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 22690 invoked from network); 15 Apr 2010 18:43:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Apr 2010 18:43:55 -0000 Received: (qmail 11318 invoked by uid 500); 15 Apr 2010 18:43:55 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 11286 invoked by uid 500); 15 Apr 2010 18:43:54 -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 11278 invoked by uid 99); 15 Apr 2010 18:43:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Apr 2010 18:43:54 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jbryanlewis@gmail.com designates 72.14.220.153 as permitted sender) Received: from [72.14.220.153] (HELO fg-out-1718.google.com) (72.14.220.153) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Apr 2010 18:43:46 +0000 Received: by fg-out-1718.google.com with SMTP id 22so690278fge.10 for ; Thu, 15 Apr 2010 11:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:content-type; bh=95R9yZjV4YcIumk3vPLjVy6vPDv+5BkXWh9vn9dwzxU=; b=Re7O1848GEPhcUg3tqUlS1ATsO2zuyOKhVUK8P6BPvWn/S7jlCoHyvClhCrT9xbDSZ ACryv/yiWW4B1AZDB0ARYoXPtI39mZ88Y/ArioKdtyGDb3t/USsfU/C0T/bdnx+axolR DqbgtT0vJhK7YKvlEo73KAaQseBVlvtETwqpI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=lc++KhLHel75v+BH72Vo6mDTXqcvvG5zBze+Kapwu/0ySmZs0orlEXzqSWQMSzdO+q 55YaTvA8KrG2U9PqYta2AUuCz6U3J2p/w5rHWTPWO2YMMarUFsf/9/I7jefCz/w6/XTl DYhiqSPliQxL+W1GE4USDxHEfzJ7IFsRuAk0Q= MIME-Version: 1.0 Received: by 10.223.113.17 with HTTP; Thu, 15 Apr 2010 11:43:26 -0700 (PDT) In-Reply-To: References: Date: Thu, 15 Apr 2010 14:43:26 -0400 Received: by 10.223.144.79 with SMTP id y15mr199378fau.22.1271357006352; Thu, 15 Apr 2010 11:43:26 -0700 (PDT) Message-ID: Subject: Re: OptimisticLocking exception during cascade delete From: Bryan Lewis To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=0023545bd638bf139f04844ade8a X-Virus-Checked: Checked by ClamAV on apache.org --0023545bd638bf139f04844ade8a Content-Type: text/plain; charset=ISO-8859-1 Hmm, that's very strange. Now the double deletion isn't happening. I don't think I changed anything relevant but I can't make it happen now. Oh well, never mind. On Thu, Apr 15, 2010 at 12:32 PM, Bryan Lewis wrote: > I have an entity Quote with a to-many relationship to QuoteCountry, and a > cascade delete rule. When I delete a quote object, Cayenne attempts to > delete the QuoteCountry objects twice, I suspect because I also have a > flattened relationship quote.countries (Quote -> QuoteCountry -> Country). > > I was googling for previous reports of this and found none, but I did come > across an old copy of Cayenne's DataContext.java that explicitly checked for > deleting twice in the presence of a flattened relationship. > > Normally this double deletion might not be noticed, but it throws an > OptimisticLockException if optimistic locking is enabled on the Quote > entity. My current work-around is to disable OL on this entity only, which > isn't a bad work-around for me. BatchAction does: > > int updated = statement.executeUpdate(); > if (useOptimisticLock && updated != 1) { > //... > throw new OptimisticLockException(...); > > --0023545bd638bf139f04844ade8a--