Re: EO: Should I create primary keys?
Re: EO: Should I create primary keys?
- Subject: Re: EO: Should I create primary keys?
- From: Art Isbell <email@hidden>
- Date: Mon, 28 Jul 2003 21:34:25 -1000
On Monday, July 28, 2003, at 05:42 PM, Denis Stanton wrote:
type.addToVehicles(newVehicle); // adds the vehicle to the
array of vehicles for this type
newVehicle.setType(type); // sets the foreign key in my
Vehicle
instance to point to my Type instance.
For those wondering about addObjectToBothSidesOfRelationshipWithKey(),
the above 2 statements could be replaced with:
type.addObjectToBothSidesOfRelationshipWithKey(newVehicle, "vehicles");
or equivalently:
newVehicle.addObjectToBothSidesOfRelationshipWithKey(type, "type");
An advantage of invoking addObjectToBothSidesOfRelationshipWithKey()
is that it will do the right thing regardless of whether an inverse
relationship exists, so it can always be used to set a relationship
value, either to-one or to-many. Invoking it instead of direct
relationship setter methods also ensures that you won't neglect to set
both sides of the relationship.
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.