Re: Problem in Many-Many Relationship
Re: Problem in Many-Many Relationship
- Subject: Re: Problem in Many-Many Relationship
- From: james o <email@hidden>
- Date: Wed, 9 Apr 2003 10:18:42 -0400
On Tuesday, April 8, 2003, at 09:43 PM, Art Isbell wrote:
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);
meena, UserRole needs to create relationships to both Users and Roles
selected objects.
UserRole currentRole;
Role roleSelected;
Users userSelected;
public WOComponent saveCurrentRole() {
currentRole = new UserRole();
//create relationship to roleSelected : "roles" is your
"currentRole" <<->> "Roles" relationship name creating
currentRole.addObjectToBothSidesOfRelationshipWithKey( roleSelected,
"roles");
//create relationship to userSelected : "users" is your "currentRole"
<<->> "Users" relationship name
currentRole.addObjectToBothSidesOfRelationshipWithKey( userSelected,
"users");
editingContext.saveChanges();
return null;
}
hth,
./me
_______________________________________________
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.