Re: Problem in Many-Many Relationship
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.