• 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
Re: Newbie vs Many-To-Many (0 win-1 win)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie vs Many-To-Many (0 win-1 win)


  • Subject: Re: Newbie vs Many-To-Many (0 win-1 win)
  • From: Art Isbell <email@hidden>
  • Date: Sat, 1 Mar 2003 11:16:50 -1000

On Friday, February 28, 2003, at 02:45  PM, Riccardo De Menna wrote:

I have to entities, Clients and Contacts. Contacts has a nice "Profile" component with a WOBrowser that lists the Clients to which you can connect the record. The submission of this page immediately saves the editing context. It work's fine and data is correctly added to db's but, when I switch to check the "Client" profile (where I should see the newly added Contact), the record is not there.
If I quit and restart the application though, the changes are reflected and everything is ok. I assume the problem has to do with the fact that I've missed the part where I also update the Client.contacts array in memory (even though the db's are already populated with correct data). But I'm confused on what should I do.
Should I use the addObjectToPropertyWithKey or addObjectToBothSidesOfRelationshipWithKey when saving the editing context? Even if I'm just updating a record and not adding? Or should I simply refetch everything so that the new configuration is loaded?

You should always use addObjectToBothSidesOfRelationshipWithKey() which works regardless of whether the relationship is to-one, to-many, flattened, or has no inverse relationship (i.e., no "other side"). addObjectToBothSidesOfRelationshipWithKey() invokes addObjectToPropertyWithKey() for the relationship whose key is specified and its inverse relationship, if it exists.


If you used addObjectToPropertyWithKey(), I think you've analyzed the results correctly; the inverse relationship, Client.contacts, wasn't updated in memory when you updated Contact.clients.

Art
http://homepage.mac.com/aisbell/
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Newbie vs Many-To-Many (0 win-1 win)
      • From: Riccardo De Menna <email@hidden>
  • Prev by Date: Re: SOLVED Prefetch Problem (Prefetching)
  • Next by Date: Multiple Row update
  • Previous by thread: Re: SOLVED Prefetch Problem (Prefetching)
  • Next by thread: Re: Newbie vs Many-To-Many (0 win-1 win)
  • Index(es):
    • Date
    • Thread