Re: EO: Should I create primary keys?
Re: EO: Should I create primary keys?
- Subject: Re: EO: Should I create primary keys?
- From: Denis Stanton <email@hidden>
- Date: Wed, 30 Jul 2003 09:56:59 +1200
Excellent. Thank you very much Art for setting this out. I was aware
of addObjectToBothSidesOfRelationshipWithKey but I wasn't confident of
the parameter definition so I have stuck with what I know works. You
have moved me on a step.
Denis
On Tuesday, July 29, 2003, at 07:34 PM, Art Isbell wrote:
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.
Denis Stanton
email@hidden
Home: (09) 533 0391
mobile: 021 1433622
_______________________________________________
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.