• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
A Bad Bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A Bad Bug?


  • Subject: A Bad Bug?
  • From: Kieran Kelleher <email@hidden>
  • Date: Tue, 19 Sep 2006 12:24:05 -0400

Here is one that bit me bad yesterday. I am trying to understand if it is really a bug situation or not, or whether the code I used is expected to produce unpredictable behavior like this did.

I was using eoSourceObject.takeValueForKey( destObject, relationshipKey ) to set a relationship. Upon saving the eoSourceObject had the corrected related object and the editing context state was correct with the relationship made, etc. I could navigate the EC and objects in the EC using the DebugMarker and ec examination pages in Project Wonder. SO basically as far as the EOF was concerned, all changes had been saved and the current state of the EC reflected the current state of the database. 

However the foreign key was actually not getting updated in the eoSourceObject table. Logging SQL showed that indeed this was the case. The source object was written out to the database with the old foreign key even though the ec had the new related object!

Now digging a little deeper, the takeValueForKey was calling the auto-eogenerated code which in turn called takeStoredValueForKey (CTMediaTemplate is the destination object here and this method is in the eogenerated _CTCampaign, the source object.)
    public void setMediaTemplate(CTMediaTemplate aValue) {
        if( log.isDebugEnabled() ) log.debug( "updating mediaTemplate from "+mediaTemplate()+" to "+aValue );
        takeStoredValueForKey(aValue, "mediaTemplate");
    }

At face value, it seemed like everything was fine and confirmation pages of the saved state of the EC showed everything OK ..... but later once the snapshot expired, the snapshot got updated form the database and the OLD original foreign key showed up and then the wrong related destObject was displayed ..... AAARRRGGGHHH!!!

The SOLUTION was to change my code to use
eoSourceObject.addObjectToBothSidesOfRelationshipWithKey( destObject, relationshipKey);

.....but WHY does not takeValueForKey or takeStoredValueForKey not set the relationship both ways?

Kieran


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: A Bad Bug?
      • From: Robert Walker <email@hidden>
    • Re: A Bad Bug?
      • From: Ken Anderson <email@hidden>
  • Prev by Date: AjaxUpdateContainer function not defined [SOLVED]
  • Next by Date: Re: A Bad Bug?
  • Previous by thread: Re: WOApp disappearing
  • Next by thread: Re: A Bad Bug?
  • Index(es):
    • Date
    • Thread