Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 19977 invoked from network); 8 Oct 2009 13:29:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Oct 2009 13:29:59 -0000 Received: (qmail 99048 invoked by uid 500); 8 Oct 2009 13:29:58 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 99012 invoked by uid 500); 8 Oct 2009 13:29:58 -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 99002 invoked by uid 99); 8 Oct 2009 13:29:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2009 13:29:58 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.85.218.212] (HELO mail-bw0-f212.google.com) (209.85.218.212) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2009 13:29:48 +0000 Received: by bwz8 with SMTP id 8so7883743bwz.4 for ; Thu, 08 Oct 2009 06:29:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.2.211 with SMTP id 19mr1091225bkk.6.1255008567105; Thu, 08 Oct 2009 06:29:27 -0700 (PDT) In-Reply-To: <47e96cf20910071748p5852b83bx1291ed13cf22b99f@mail.gmail.com> References: <89FAAF97-90C2-4EF4-AE60-C8E57360AB30@gmail.com> <3219fff70910070043v7fd9d25eka8a876a71219da75@mail.gmail.com> <3219fff70910070051pd7526ferf0084704acd8ac37@mail.gmail.com> <47e96cf20910070158y13989947i93a5a880cc396ff@mail.gmail.com> <3219fff70910070207o283c6b5fo2c95cdcc363c2cd3@mail.gmail.com> <47e96cf20910070225v2561be44s48970c27ca649be0@mail.gmail.com> <3219fff70910070353k9e44baajd3445ca65d2e720e@mail.gmail.com> <47e96cf20910071748p5852b83bx1291ed13cf22b99f@mail.gmail.com> Date: Thu, 8 Oct 2009 09:29:27 -0400 Message-ID: <5adb61290910080629u4afa94e8tcf9deb6afe0e1426@mail.gmail.com> Subject: Re: Hollow object throwing FaultFailureException From: Michael Gentry To: user@cayenne.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Lawrence, I think SQLResultSetMapping became SQLResult in M6. mrg On Wed, Oct 7, 2009 at 8:48 PM, Lawrence Gerstley wrote= : > Hello Andrey, > I'm using 3.0M4, and just finished checking it with 3.0M5 (same thing > happens). I'm not able to use 3.0M6, because it looks as if * > org.apache.cayenne.query.SQLResultSetMapping* is missing from the build (= at > least it's not in my jar, and missing from the documentation). > > To troubleshoot, I've looked at the collection returned from * > getGraphManager().registeredNodes()* before and after the * > unregisterNode(node)* call, and the call seems to have no effect. > > If I'm not misunderstanding this, I can log it in Jira--I've opened an > account there. I was just concerned that I was going about it incorrectly= . > > Cheers--Lawrence > > On Wed, Oct 7, 2009 at 4:53 AM, Andrey Razumovsky < > razumovsky.andrey@gmail.com> wrote: > >> What version of Cayenne are you using? I can have a look. To speed up >> things, you can submit a JUnit test >> >> 2009/10/7 Lawrence Gerstley >> >> > Of course it doesn't. Sorry--it's past 2AM and I'm getting sloppy. >> However, >> > I made the change, and unregistered the object, then tried the assignm= ent >> > immediately thereafter and still encounter the same error: >> > =A0 =A0 =A0 =A0 =A0 =A0this.entityAssnsToEntity =3D >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(Entityassnstoentity) childDc.localObje= ct( >> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.entityAssnsToEnti= ty.getObjectId(), >> > this.entityAssnsToEntity); >> > =A0 =A0 =A0 =A0 =A0 =A0 Entrystate oldEntryState =3D >> > this.entityAssnsToEntity.getToEntryState(); >> > >> > >> > >> =A0entityAssnsToEntity.getObjectContext().getGraphManager().unregisterNo= de(oldEntryState); >> > =A0 =A0 =A0 =A0 =A0 =A0 entityAssnsToEntity.setToEntryState(entryState= ); >> > =A0 =A0 =A0 =A0 =A0 =A0childDc.commitChanges(); >> > >> > The error: "No matching row exists in the database for ObjectId: >> > > ...>" >> > >> > On Wed, Oct 7, 2009 at 3:07 AM, Andrey Razumovsky < >> > razumovsky.andrey@gmail.com> wrote: >> > >> > > localObject() function doesn't mutate its arguments. This should be >> > > rewritten as >> > > this.entityAssnsToEntity =3D >> > > childDc.localObject(this.entityAssnsToEntity.getObjectId(), >> > > this.entityAssnsToEntity); >> > > >> > > (or create a local variable). Relationships between contexts are not >> > > allowed >> > > >> > > 2009/10/7 Lawrence Gerstley >> > > >> > > > Hi, >> > > > So I'm trying the invalidation, but cannot do the follow-on >> assignment >> > > due >> > > > to the objects existing in different contexts. I created a nested >> > context >> > > > for the creation of the healed row, as I wanted to commit that and >> > > nothing >> > > > else change-wise from the DataContext--reason: the user might canc= el >> > any >> > > > ongoing changes, but the healed row should be written as soon as i= t's >> > > > detected. However, now I can't make the assignment due to the pare= nt >> > > record >> > > > existing in the parent context, and still fails when I try to move >> the >> > > > parent record to the nested context. Thus: >> > > > >> > > > try { >> > > > =A0System.out.println( >> > > this.entityAssnsToEntity.getToEntryState().getOwner(); >> > > > } catch (FaultFailureException e) { >> > > > =A0DataContext childDc =3D dc.createChildDataContext(); >> > > > // Create new EntryState with builder pattern >> > > > =A0entryState =3D (Entrystate)ItemDirector.buildItem(new >> > EntryStateBuilder(), >> > > > childDc); >> > > > =A0childDc.localObject(this.entityAssnsToEntity.getObjectId(), >> > > > this.entityAssnsToEntity); >> > > > >> > > > >> > > >> > >> =A0this.entityAssnsToEntity.getObjectContext().getGraphManager().unregis= terNode( >> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0this.entityAssnsToEntity.ge= tToEntryState()); >> > > > =A0this.entityAssnsToEntity.setToEntryState(entryState); >> > > > =A0childDc.commitChanges(); >> > > > } >> > > > >> > > > ...fails due to "Cannot set object as destination of relationship >> > > > toEntryState because it is in a different ObjectContext" >> > > > >> > > > Something must be missing here--am I off-track? >> > > > >> > > > Thanks--Lawrence >> > > > On Wed, Oct 7, 2009 at 1:51 AM, Andrey Razumovsky < >> > > > razumovsky.andrey@gmail.com> wrote: >> > > > >> > > > > Or, try to unregister HOLLOW object (using >> > > > > context.getGraphManager().unregisterNode()) before any changes >> > > > > >> > > > > 2009/10/7 Andrey Razumovsky >> > > > > >> > > > > > Hi, >> > > > > > >> > > > > > I think this happens because HOLLOW object instance is not the >> same >> > > as >> > > > > NEW >> > > > > > object you're creaing. To get rid of HOLLOW object, I reccomen= d >> > > > > invalidating >> > > > > > ENTITYASSNSTOENTITY that points to missing row after healing t= hat >> > row >> > > > > (using >> > > > > > ObjectContext.invalidateObjects()). >> > > > > > >> > > > > > Hope this helps, >> > > > > > >> > > > > > 2009/10/7 Lawrence Gerstley >> > > > > > >> > > > > > =A0Hello, >> > > > > >> >> > > > > >> I've searched back through old postings and seen a little bit >> > about >> > > > this >> > > > > >> back in V2, but nothing recently. Was wondering if anyone had >> any >> > > idea >> > > > > how >> > > > > >> to handle this problem: >> > > > > >> >> > > > > >> Take a model including two tables: ENTITYASSNTOENTITY and >> > > ENTRYSTATE, >> > > > > >> where the column ENTRYSTATEID is present in both. >> > > > > >> ENTITYASSNTOENTITY.ENTRYSTATEID is a FK to >> ENTRYSTATE.ENTRYSTATEID >> > > > > (Primary >> > > > > >> Key). This is modeled as a one-to-one relationship. >> > > > > >> >> > > > > >> Problematically, it is possible for the ENTRYSTATEID in >> > > > > >> ENTITYASSNSTOENTITY to have a key populated in it that is now >> > > missing >> > > > in >> > > > > >> ENTRYSTATE. Certainly, this breaks integrity, but that's not >> under >> > > my >> > > > > >> control for historical and other reasons. Thus, when I have a= n >> > > > > >> ENTITYASSNSTOENTITY, such as eate1, and I want to get to the >> > related >> > > > > >> ENTRYSTATE with a "toEntryState" method, I get a hollow objec= t >> > that >> > > > > refers >> > > > > >> to a missing ENTRYSTATE record. If I try to access any fields >> > within >> > > > > that >> > > > > >> record, I get and catch a "FaultFailureException", indicating >> that >> > I >> > > > > have no >> > > > > >> matching row in the database. That's all fine. >> > > > > >> >> > > > > >> What I need to do is to gracefully handle the error by allowi= ng >> > the >> > > > > >> database to "self-heal" from such a missing record. I want to >> > > populate >> > > > > the >> > > > > >> hollow object with values and commit it to reinsert a row in = the >> > > > > database to >> > > > > >> correct for the integrity error, or create a new ENTRYSTATE >> object >> > > to >> > > > > take >> > > > > >> the place of the hollow and absent one. I tried to create a >> > > > > >> childDataContext, move the hollow and absent ENTRYSTATE recor= d >> to >> > > it, >> > > > > >> populate, then commitChanges, but this still throws a follow-= on >> > > > > exception >> > > > > >> for the missing row. If I create a new ENTRYSTATE and try to >> > attach >> > > it >> > > > > with >> > > > > >> eate1.setToEntryState(newEntryState), I also get the same err= or >> > > > related >> > > > > to >> > > > > >> the absent record. When the application is restarted, however= , >> all >> > > > works >> > > > > >> fine, because the missing record was committed and persisted, >> and >> > > now >> > > > no >> > > > > >> exceptions are thrown. The issue is that I want to handle thi= s >> > > > > gracefully >> > > > > >> with no necessary reloading. >> > > > > >> >> > > > > >> Reading from previous postings, I saw some information on hav= ing >> > to >> > > > > treat >> > > > > >> the relationship as a many-to-one, and handling it with cover= ing >> > > > > methods. Is >> > > > > >> this the only fix for this issue? Should I commit the missing >> > > record, >> > > > > >> invalidate the state of the ENTITYASSNSTOENTITY object and >> reload? >> > > > > >> >> > > > > >> As always. thanks for any ideas you might have. >> > > > > >> >> > > > > >> Cheers--Lawrence >> > > > > >> >> > > > > > >> > > > > > >> > > > > > >> > > > > > -- >> > > > > > Andrey >> > > > > > >> > > > > >> > > > > >> > > > > >> > > > > -- >> > > > > Andrey >> > > > > >> > > > >> > > > >> > > > >> > > > -- >> > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D >> > > > Lawrence Gerstley, Ph.D. >> > > > PSMI Consulting >> > > > >> > > > Cel: 415.694-0844 >> > > > >> > > >> > > >> > > >> > > -- >> > > Andrey >> > > >> > >> > >> > >> > -- >> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >> > Lawrence Gerstley, Ph.D. >> > PSMI Consulting >> > >> > Cel: 415.694-0844 >> > >> >> >> >> -- >> Andrey >> > > > > -- > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > Lawrence Gerstley, Ph.D. > PSMI Consulting > > Cel: 415.694-0844 >