• 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: Wed, 9 Apr 2003 10:12:49 -1000

On Wednesday, April 9, 2003, at 04:18  AM, james o wrote:

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;
}

The above won't work and shouldn't be necessary.

It won't work because currentRole was never inserted into the editing context and the currentRole.roles and currentRole.users relationships should be to-one, not to-many (i.e., currentRole.role and currentRole.user).

It shouldn't be necessary unless UserRole objects are meaningful to the WO app. If UserRole has class properties (its primary key attributes shouldn't be class properties), then the flattened Role.toUsers and User.toRoles relationships should be deleted and the underlying relationships among Role, UserRole, and User that are significant to the WO app should be made class properties. That would result in code similar to the following:

currentRole = new UserRole();
editingContext.insertObject(currentRole);
currentRole.addObjectToBothSidesOfRelationshipWithKey(roleSelected, "role");
currentRole.addObjectToBothSidesOfRelationshipWithKey(userSelected, "user");
editingContext.saveChanges();


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.

References: 
 >Re: Problem in Many-Many Relationship (From: james o <email@hidden>)

  • Prev by Date: Re: Problem in Many-Many Relationship
  • Next by Date: Nib Files
  • Previous by thread: Re: Problem in Many-Many Relationship
  • Next by thread: Re: Problem in Many-Many Relationship
  • Index(es):
    • Date
    • Thread