Return-Path: Delivered-To: apmail-incubator-cayenne-dev-archive@locus.apache.org Received: (qmail 22777 invoked from network); 13 Sep 2006 20:09:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Sep 2006 20:09:50 -0000 Received: (qmail 19508 invoked by uid 500); 13 Sep 2006 20:09:50 -0000 Delivered-To: apmail-incubator-cayenne-dev-archive@incubator.apache.org Received: (qmail 19478 invoked by uid 500); 13 Sep 2006 20:09:50 -0000 Mailing-List: contact cayenne-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cayenne-dev@incubator.apache.org Delivered-To: mailing list cayenne-dev@incubator.apache.org Received: (qmail 19469 invoked by uid 99); 13 Sep 2006 20:09:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Sep 2006 13:09:49 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of mkienenb@gmail.com designates 64.233.162.195 as permitted sender) Received: from [64.233.162.195] (HELO nz-out-0102.google.com) (64.233.162.195) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Sep 2006 13:09:42 -0700 Received: by nz-out-0102.google.com with SMTP id v1so1203988nzb for ; Wed, 13 Sep 2006 13:09:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=EidYMXI9STa9ePixvL1S+iDRWVaAdM4+nBDD+fEVLuLt4anyNpYBmX+ySiPpeQDfrM0SzwXXMgxnROhzAWoDRcxcOikIAq+H0x/lcWJ1vtyHYKs/zcU0RVdR6NcuyVCuuZ5cTrULQJK0kECLUgRRaPo2Rb3Q+xBQbPkjcQeLTp0= Received: by 10.65.119.14 with SMTP id w14mr8981186qbm; Wed, 13 Sep 2006 12:59:14 -0700 (PDT) Received: by 10.65.253.9 with HTTP; Wed, 13 Sep 2006 12:59:14 -0700 (PDT) Message-ID: <8f985b960609131259p5b3303ffgff46d9477d3c968e@mail.gmail.com> Date: Wed, 13 Sep 2006 15:59:14 -0400 From: "Mike Kienenberger" To: cayenne-dev@incubator.apache.org Subject: Optimistic locking fails if primary key is used in an ObjRelationship -- CAY-595 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I turned optimistic locking on for my 1.2.1 application, and updates started failing. I was getting output like the following where AUTHORIZATION_DOCUMENT_ID is the primary key. UPDATE ENG_WORK_MGMT.AUTHORIZATION_DOCUMENT SET PROJECT_NAME = ? WHERE AUTHORIZATION_DOCUMENT_ID IS NULL AND [...] The problem appears to be in org.objectstyle.cayenne.access.DataNodeSyncQualifierDescriptor.reset() // relationship transformers override attribute transformers for // meaningful FK's... why meanigful FKs can go out of sync is // another story (CAY-595) int index = attributes.indexOf(dbAttribute); if (index >= 0 && !dbAttribute.isForeignKey()) { continue; } However, if there's an ObjRelationship to a dependent entity, this relationship transform will also replace the primary key transformer previously defined. [1] I changed it to if (index >= 0 && (!dbAttribute.isForeignKey() || dbAttribute.isPrimaryKey())) { and the unit tests all seem to pass. I can't think of any reason to not use the primary key transformers in all cases. In fact, I'm wondering if it shouldn't simply be if (dbAttribute.isPrimaryKey()) { continue; } int index = attributes.indexOf(dbAttribute); if (index >= 0 && !dbAttribute.isForeignKey()) { continue; } [1] Ie, I have a dependentPermitDocument relationship and a dependentEasementDocument relationship as both PermitDocument and EasementDocument are vertical inheritance subclasses of AuthorizationDocument. At least I'm guessing this was the relationship that caused the failure -- unchecking the locking on the two relationships didn't solve the problem for me, but maybe I missed something.