• 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: 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.

  • Follow-Ups:
    • Re: Problem in Many-Many Relationship
      • From: Art Isbell <email@hidden>
References: 
 >Re: Problem in Many-Many Relationship (From: Art Isbell <email@hidden>)

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