• 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: Problem in Many-Many Relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem in Many-Many Relationship


  • Subject: Re: Problem in Many-Many Relationship
  • From: Art Isbell <email@hidden>
  • Date: Tue, 8 Apr 2003 15:43:36 -1000

On Monday, April 7, 2003, at 11:32  PM, Meena Srinivasan wrote:

I have two tables, "Role" and "Users"  which has a many-to-many
relationship, thus resulting in "UserRole".   That is, "UserRole" just
has the primary key of "Role" and the primary key of "Users" and there
are no other attributes in "UserRole".

"Role" has an instance "currentRole" and "Users" has an instance
"selectedUser".  Therefore, on save,  I use the following piece of code
to insert the record in "UserRole"

currentRole.addToToUsers(selectedUser);

Should be:

currentRole.addObjectToBothSidesOfRelationshipWithKey(selectedUser, "ToUsers");

Adding an object to a to-many relationship involves the insertion of a UserRole record as well as setting several relationship values. In general, add/removeObjectTo/FromBothSidesOfRelationshipWithKey() should be used when modifying any relationship, not just many-to-many relationships.

Aloha,
Art
_______________________________________________
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: Problem in Many-Many Relationship
      • From: james o <email@hidden>
References: 
 >Problem in Many-Many Relationship (From: Meena Srinivasan <email@hidden>)

  • Prev by Date: Re: Problem in Many-Many Relationship
  • Next by Date: Re: New to webobjects
  • Previous by thread: Re: Problem in Many-Many Relationship
  • Next by thread: Re: Problem in Many-Many Relationship
  • Index(es):
    • Date
    • Thread