Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 81B051032A for ; Thu, 19 Sep 2013 16:12:47 +0000 (UTC) Received: (qmail 7733 invoked by uid 500); 19 Sep 2013 16:12:47 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 7601 invoked by uid 500); 19 Sep 2013 16:12:41 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 7566 invoked by uid 99); 19 Sep 2013 16:12:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Sep 2013 16:12:39 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mkienenb@gmail.com designates 209.85.212.181 as permitted sender) Received: from [209.85.212.181] (HELO mail-wi0-f181.google.com) (209.85.212.181) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Sep 2013 16:12:33 +0000 Received: by mail-wi0-f181.google.com with SMTP id ex4so8275219wid.8 for ; Thu, 19 Sep 2013 09:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=TFbdum9ZYabEe+ExRBGTMMi0V5JfJodM7bpteGvLpzk=; b=fqXHRRC6mqBdLHyZM64RY7Pf/0bD52xqh3qzOTgu22E9mnucnTkxH6YGW2oW79GPxI W5z5mKKYAI0AIYf8qyXhL3Jcuib8lzG+vlX4vEtr+Q/T/QWMfiVYqINMR9Otv0BfvXYK +4sFTLr5+OPqzHdzAk53RUaFh+DfG/cMU0ImQgI1+xys4cwUksETBhsKSr+X+YE2+2Av NtImJ7ZAXSBgu9SadhWa99HNk8EIXcmNxnuFxvmbCH3pf8E/GQkJtPaEj1bIm/a6UrCn ACqZsx9tANjaU2TJG/N3QKdFXPNfvyZnnWcmVlyEv/t+i11otweMT9rtQtS9jrV3fcRb gUmQ== X-Received: by 10.180.210.243 with SMTP id mx19mr12105269wic.35.1379607133096; Thu, 19 Sep 2013 09:12:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.213.8 with HTTP; Thu, 19 Sep 2013 09:11:53 -0700 (PDT) In-Reply-To: <8324F82B-EB6F-4306-97AE-CA21C0911C65@objectstyle.org> References: <1B5A4E4F-4462-4B34-851A-2DD25B505D8A@objectstyle.org> <6D572624-AB4F-473F-AD91-ED5390117658@objectstyle.org> <8324F82B-EB6F-4306-97AE-CA21C0911C65@objectstyle.org> From: Mike Kienenberger Date: Thu, 19 Sep 2013 12:11:53 -0400 Message-ID: Subject: Re: optimistic locking exception due to locking on not "Used For Locking" null to-one relationship To: dev@cayenne.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org It got rid of a couple of errors when I copied this change from trunk to 3.0, and then deleted/re-imported the maven project. But I still have these 7 maven errors remaining (and many java errors on the optional projects): Description Resource Path Location Type Plugin execution not covered by lifecycle configuration: org.objectstyle.woproject.maven2:maven-japplication-plugin:2.0.17:japplicat= ion (execution: default, phase: generate-resources) pom.xml /cayenne-modeler-mac line 89 Maven Project Build Lifecycle Mapping Problem Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:javacc-maven-plugin:2.5:jjtree (execution: jjtree-ejbql, phase: generate-sources) pom.xml /cayenne-jdk1.5-unpublished line 156 Maven Project Build Lifecycle Mapping Problem Plugin execution not covered by lifecycle configuration: org.objectstyle.woproject.maven2:maven-japplication-plugin:2.0.17:japplicat= ion (execution: default, phase: generate-resources) pom.xml /cayenne-modeler-java line 77 Maven Project Build Lifecycle Mapping Problem Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:javacc-maven-plugin:2.5:javacc (execution: javacc-ejbql, phase: generate-sources) pom.xml /cayenne-jdk1.5-unpublished line 172 Maven Project Build Lifecycle Mapping Problem Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:javadoc (execution: javadoc, phase: generate-resources) pom.xml /cayenne-doc line 210 Maven Project Build Lifecycle Mapping Problem Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:dependency-maven-plugin:1.0:unpack (execution: unpack-sources, phase: generate-sources) pom.xml /cayenne-doc line 179 Maven Project Build Lifecycle Mapping Problem Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-remote-resources-plugin:1.4:bundle (execution: default, phase: generate-resources) pom.xml /cayenne-legal-unpublished line 65 Maven Project Build Lifecycle Mapping Problem On Thu, Sep 19, 2013 at 11:19 AM, Andrus Adamchik wrote: > Aha, just found what you need. Check the root pom.xml on trunk. Locate th= is section: > > > > > > org.eclipse.m2e > lifecycle-mapping > 1.0.0 > > > =85 > > > You will need to drop =85 part for lifecycle-mapping plu= gin into 3.0 root pom. Let me know if you have any trouble with this. I'll = do it myself. > > Andrus > > > > > On Sep 19, 2013, at 5:46 PM, Andrus Adamchik wro= te: > >> You can exclude cayenne-legal-unpublished. >> >>> Release Build id: 20120614-1722 >> >> I happen to have the same version of Eclipse. What's the m2eclipse (Mave= n plugin) version? Mine is 1.1.0.20120530-0009. And IIRC it allows you to i= gnore all these errors explicitly on import. >> >> Andrus >> >> >> >> On Sep 18, 2013, at 8:27 PM, Mike Kienenberger wrot= e: >> >>> After closing the modeler, doc, and tutorial projects, I am left with >>> these unresolved errors: >>> >>> Description Resource Path Location Type >>> Plugin execution not covered by lifecycle configuration: >>> org.apache.cayenne.build-tools:maven-cayenne-build-plugin:3.2M1:date >>> (execution: date, phase: initialize) pom.xml >>> /cayenne-jdk1.6-unpublished line 78 Maven Project Build >>> Lifecycle Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.apache.maven.plugins:maven-remote-resources-plugin:1.4:bundle >>> (execution: default, phase: generate-resources) pom.xml >>> /cayenne-legal-unpublished line 65 Maven Project Build Lifecycle >>> Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.apache.cayenne.build-tools:maven-cayenne-build-plugin:3.2M1:date >>> (execution: date, phase: initialize) pom.xml >>> /cayenne-legal-unpublished line 53 Maven Project Build Lifecycle >>> Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.objectstyle.woproject.maven2:maven-japplication-plugin:2.0.17:jappl= ication >>> (execution: default, phase: generate-resources) pom.xml >>> /cayenne-modeler-java line 77 Maven Project Build Lifecycle >>> Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.apache.maven.plugins:maven-antrun-plugin:1.3:run (execution: >>> default, phase: process-sources) pom.xml >>> /cayenne-jdk1.5-unpublished line 214 Maven Project Build >>> Lifecycle Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.codehaus.mojo:javacc-maven-plugin:2.5:javacc (execution: >>> javacc-ejbql, phase: generate-sources) pom.xml >>> /cayenne-jdk1.5-unpublished line 172 Maven Project Build >>> Lifecycle Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.codehaus.mojo:javacc-maven-plugin:2.5:jjtree (execution: >>> jjtree-ejbql, phase: generate-sources) pom.xml >>> /cayenne-jdk1.5-unpublished line 156 Maven Project Build >>> Lifecycle Mapping Problem >>> Plugin execution not covered by lifecycle configuration: >>> org.apache.cayenne.build-tools:maven-cayenne-build-plugin:3.2M1:date >>> (execution: date, phase: initialize) pom.xml >>> /cayenne-jdk1.5-unpublished line 263 Maven Project Build >>> Lifecycle Mapping Problem >>> >>> >>> >>> On Wed, Sep 18, 2013 at 1:25 PM, Mike Kienenberger = wrote: >>>> All 2100+ tests for my own project now pass under my modified 3.0.2. >>>> >>>> However, I'm having problems getting a STABLE-3.0 development >>>> environment set up under Eclipse so that I can investigate the failing >>>> cayenne tests. >>>> >>>> I tried following the directions under >>>> http://cayenne.apache.org/dev/eclipse.html using Eclipse Version: Juno >>>> Release Build id: 20120614-1722 but after the process created 37 >>>> projects in the workspace, I'm still left with 243 java compile errors >>>> and 13 maven problems. >>>> >>>> The java errors seem like tutorial or modeler errors which I can >>>> probably ignore. (like no com.apple imports). >>>> >>>> I'm not sure what to make of the maven errors as some of these are in >>>> primary modules. >>>> >>>> Description Resource Path Location Type >>>> Plugin execution not covered by lifecycle configuration: >>>> org.apache.cayenne.build-tools:maven-cayenne-build-plugin:3.2M1:date >>>> (execution: date, phase: initialize) pom.xml >>>> /cayenne-jdk1.6-unpublished line 78 Maven Project Build >>>> Lifecycle Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.apache.maven.plugins:maven-remote-resources-plugin:1.4:bundle >>>> (execution: default, phase: generate-resources) pom.xml >>>> /cayenne-legal-unpublished line 65 Maven Project Build Lifecycle >>>> Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.apache.cayenne.build-tools:maven-cayenne-build-plugin:3.2M1:date >>>> (execution: date, phase: initialize) pom.xml >>>> /cayenne-legal-unpublished line 53 Maven Project Build Lifecycle >>>> Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.objectstyle.woproject.maven2:maven-japplication-plugin:2.0.17:japp= lication >>>> (execution: default, phase: generate-resources) pom.xml >>>> /cayenne-modeler-java line 77 Maven Project Build Lifecycle >>>> Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.apache.maven.plugins:maven-antrun-plugin:1.3:run (execution: >>>> default, phase: process-sources) pom.xml >>>> /cayenne-jdk1.5-unpublished line 214 Maven Project Build >>>> Lifecycle Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.codehaus.mojo:javacc-maven-plugin:2.5:javacc (execution: >>>> javacc-ejbql, phase: generate-sources) pom.xml >>>> /cayenne-jdk1.5-unpublished line 172 Maven Project Build >>>> Lifecycle Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.codehaus.mojo:javacc-maven-plugin:2.5:jjtree (execution: >>>> jjtree-ejbql, phase: generate-sources) pom.xml >>>> /cayenne-jdk1.5-unpublished line 156 Maven Project Build >>>> Lifecycle Mapping Problem >>>> Plugin execution not covered by lifecycle configuration: >>>> org.apache.cayenne.build-tools:maven-cayenne-build-plugin:3.2M1:date >>>> (execution: date, phase: initialize) pom.xml >>>> /cayenne-jdk1.5-unpublished line 263 Maven Project Build >>>> Lifecycle Mapping Problem >>>> >>>> >>>> >>>> >>>> >>>> On Sun, Sep 15, 2013 at 3:59 AM, Andrus Adamchik wrote: >>>>> Hi Mike, >>>>> >>>>> So looks like you are on top of it=85 Let me know if you need any hel= p. >>>>> >>>>> Andrus >>>>> >>>>> >>>>> >>>>> On Sep 14, 2013, at 8:22 AM, Mike Kienenberger w= rote: >>>>>> I remembered to update the subject this time. >>>>>> >>>>>> So if I replace >>>>>> >>>>>> arcSnapshot.put(property.getName(), target); >>>>>> >>>>>> with >>>>>> >>>>>> if (property.getRelationship().isUsedForLocking()= ) { >>>>>> arcSnapshot.put(property.getName(), target)= ; >>>>>> } >>>>>> >>>>>> then the primary key qualifier is correct: "WHERE USER_ID =3D 2" ins= tead >>>>>> of "WHERE USER_ID is null." >>>>>> >>>>>> Unfortunately, this also causes several unit tests to fail. I haven= 't >>>>>> yet investigated why this might be. >>>>>> >>>>>> Failed tests: >>>>>> testReadToOneRelationship(org.apache.cayenne.access.NestedDataContex= tReadTest) >>>>>> testRemoveToMany(org.apache.cayenne.CDOSetRelationshipTest) >>>>>> testRemove(org.apache.cayenne.CDOMany2OneTest) >>>>>> testNullifyToOne(org.apache.cayenne.access.NestedDataContextWriteTes= t) >>>>>> testMultipleToOneDeletion(org.apache.cayenne.unit.jira.CAY_901Test) >>>>>> testRemoveToMany(org.apache.cayenne.CDOMapRelationshipTest) >>>>>> testPhantomRelationshipModificationValidate(org.apache.cayenne.acces= s.DataContextExtrasTest) >>>>>> testRemove1(org.apache.cayenne.CDOOne2ManyTest) >>>>>> testRemove2(org.apache.cayenne.CDOOne2ManyTest) >>>>>> testIsToOneTargetModified(org.apache.cayenne.access.DataRowUtilsTest= ) >>>>>> testRemoveToMany(org.apache.cayenne.CDOCollectionRelationshipTest) >>>>>> >>>>>> So far, basic functionality for my app seems working. >>>>>> >>>>>> On Fri, Sep 13, 2013 at 4:46 PM, Mike Kienenberger wrote: >>>>>>> As I mentioned earlier, I'm upgrading my ancient Cayenne project fr= om >>>>>>> 1.1 to 3.x, currently 3.0.2. >>>>>>> >>>>>>> I started by upgrading to 1.2 and 2.0, unfortunately hitting the ol= d >>>>>>> null-relationship-breaks-optimistic-locking error. >>>>>>> >>>>>>> http://mail-archives.apache.org/mod_mbox/cayenne-dev/200803.mbox/%3= C8f985b960803271232s5018a5a9hbf0f731f82666e6a@mail.gmail.com%3E >>>>>>> >>>>>>> Since most everything else seemed to be working, and the the >>>>>>> workaround I had for 1.1 wasn't possible in 1.2/2.0, I decided to s= kip >>>>>>> ahead to 3.0 and hope it was fixed there, or that it'd be more >>>>>>> relevant to fix there. >>>>>>> >>>>>>> But the same behavior I see in 1.2 and 2.0 still occurs in 3.0.2. = For >>>>>>> 1.1, the fix was to retain a new snapshot when resolving faults, bu= t >>>>>>> the problem here seems to be slightly different. >>>>>>> >>>>>>> My model has a "User" object and a "PotentialCustomer" object. The >>>>>>> PotentialCustomer is an optional one-to-one relationship with the >>>>>>> User, where they both have the same primary key. In the past I hav= e >>>>>>> left the PotentialCustomer relationship as "Used for Locking", >>>>>>> although I've set it both ways without changing the resulting error= . >>>>>>> >>>>>>> Committing an unrelated attribute change to the "User" object when = it >>>>>>> has no corresponding "PotentialCustomer" object generates a "where >>>>>>> USER_ID is null" clause. >>>>>>> >>>>>>> Writing a property change eventually generates an arcSnapshot for = all >>>>>>> to-one relationships, even if they are not marked for locking. >>>>>>> org.apache.cayenne.access.ObjectDiff.java - line 114: >>>>>>> >>>>>>> public boolean visitToOne(ToOneProperty property) { >>>>>>> >>>>>>> // eagerly resolve optimistically locked relations= hips >>>>>>> Object target =3D lock ? >>>>>>> property.readProperty(object) : property >>>>>>> .readPropertyDirectly(object); >>>>>>> >>>>>>> if (target instanceof Persistent) { >>>>>>> target =3D ((Persistent) target).getObjectId()= ; >>>>>>> } >>>>>>> // else - null || Fault >>>>>>> >>>>>>> arcSnapshot.put(property.getName(), target); >>>>>>> return true; >>>>>>> } >>>>>>> >>>>>>> The problem is that with a relationship which is optional, the targ= et >>>>>>> is going to be null. And later on, when we generate optimistic >>>>>>> locking qualifiers in >>>>>>> org.apache.cayenne.access.DataNodeSyncQualifierDescriptor, we store >>>>>>> this null value as the matching value for the record's primary key. >>>>>>> >>>>>>> To me, part of the fix would seem to be to not do anything if we're >>>>>>> not locking on this column. Why do we need to resolve a relations= hip >>>>>>> or store a snapshot for a column not involved in optimistic locking= ? >>>>>>> >>>>>>> Second, even if this column is involved with optimistic locking, it >>>>>>> should not be used as a replacement value for the modified object's >>>>>>> primary key. It's probably a model error to specify a relationship >>>>>>> based on the modified object's primary key as a locking column. >>>>>>> However, I can correct this by removing the "Used for Locking" valu= e. >>>>>>> >>>>>>> >>>>>>> On Thu, Mar 27, 2008 at 3:32 PM, Mike Kienenberger wrote: >>>>>>>> Here's an interesting situation I'm debugging now for Cayenne 1.1. >>>>>>>> It seems to be related to CAY-213 "NullPointerException in >>>>>>>> ContextCommit with locking". I suspect that it's true of 1.2 and >>>>>>>> could very well be true for 3.0 as well, although I don't have tha= t >>>>>>>> handy to test with. >>>>>>>> >>>>>>>> http://issues.apache.org/cayenne/browse/CAY-213 >>>>>>>> >>>>>>>> My testing seems to reveal that the same problem occurs when you s= et a >>>>>>>> to-one relationship to null. Line 291 in removeToManyTarget() set= s >>>>>>>> the state of the previous to-one relationship object to MODIFIED, = but >>>>>>>> doesn't retain a snapshot for that object. >>>>>>>> >>>>>>>> Here's some simple test code that shows the problem. And switchi= ng >>>>>>>> the scalar setter with the relationship setter works around the >>>>>>>> problem. >>>>>>>> >>>>>>>> It seems to me that the the fix is to add >>>>>>>> >>>>>>>> dataContext.getObjectStore().retainSnapshot(this); >>>>>>>> >>>>>>>> as was done for writeProperty(). >>>>>>>> >>>>>>>> >>>>>>>> public void run() throws Exception >>>>>>>> { >>>>>>>> initCayenne("cayenne.xml"); >>>>>>>> >>>>>>>> // Set up database >>>>>>>> createSchemaForObjEntityName(Configuration.getSharedConfigura= tion(), >>>>>>>> "PotentialCustomer"); >>>>>>>> DataContext dc =3D DataContext.createDataContext(); >>>>>>>> >>>>>>>> // Set up test data >>>>>>>> PotentialCustomer pc =3D >>>>>>>> (PotentialCustomer)dc.createAndRegisterNewObject(PotentialCustomer= .class); >>>>>>>> Premise premise =3D (Premise)dc.createAndRegisterNewObject(Pr= emise.class); >>>>>>>> pc.setToOneTarget("premise", premise, true); >>>>>>>> dc.commitChanges(); >>>>>>>> >>>>>>>> // Force failure: >>>>>>>> pc.setToOneTarget("premise", null, true); >>>>>>>> premise.writeProperty("altitude", new Integer(0)); >>>>>>>> >>>>>>>> // On commitChanges(), no snapshot available for building locking >>>>>>>> // java.lang.NullPointerException >>>>>>>> // at org.objectstyle.cayenne.access.ContextCommit.append= OptimisticLockingAttributes(ContextCommit.java:564) >>>>>>>> >>>>>>>> dc.commitChanges(); >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> java.lang.NullPointerException >>>>>>>> at org.objectstyle.cayenne.access.ContextCommit.appendOptimis= ticLockingAttributes(ContextCommit.java:564) >>>>>>>> at org.objectstyle.cayenne.access.ContextCommit.prepareUpdate= Queries(ContextCommit.java:426) >>>>>>>> at org.objectstyle.cayenne.access.ContextCommit.commit(Contex= tCommit.java:156) >>>>>>>> at org.objectstyle.cayenne.access.DataContext.commitChanges(D= ataContext.java:1266) >>>>>>>> at org.objectstyle.cayenne.access.DataContext.commitChanges(D= ataContext.java:1236) >>>>>>>> at com.gvea.cayenne.TestOptimisticLockingFailureOnSingleTarge= tNull.run(TestOptimisticLockingFailureOnSingleTargetNull.java:110) >>>>>>>> at com.gvea.cayenne.TestOptimisticLockingFailureOnSingleTarge= tNull.main(TestOptimisticLockingFailureOnSingleTargetNull.java:24) >>>>>>>> >>>>>>>> Note that some of these line numbers may vary as my version of Cay= enne >>>>>>>> 1.1 has local mods. >>>>>> >>>>> >>> >> >> >