Re: When do I use addObjectToBothSidesOfRelationshipWithKey?
Re: When do I use addObjectToBothSidesOfRelationshipWithKey?
- Subject: Re: When do I use addObjectToBothSidesOfRelationshipWithKey?
- From: Art Isbell <email@hidden>
- Date: Thu, 2 Sep 2004 14:00:38 -1000
On Sep 2, 2004, at 1:00 PM, Tom Jones wrote:
The code below is my attempt to preserve the following relationships
project<-->>req
reqpriority<-->>req
status<-->>req
reqtype<-->>req
a project owns its reqs
if a reqpriority, status or reqtype is deleted, the req's
corresponding value should be null.
given that is all of this code necessary?
session.defaultEditingContext().insertObject(req);
req.reqpriority().addObjectToBothSidesOfRelationshipWithKey(req,
"reqs");
req.status().addObjectToBothSidesOfRelationshipWithKey(req, "reqs");
req.reqtype().addObjectToBothSidesOfRelationshipWithKey(req, "reqs");
project.addObjectToBothSidesOfRelationshipWithKey(req,"reqs");
session.defaultEditingContext().saveChanges();
Statements 2 - 4 imply that req.reqpriority, req.status, and
req.reqtype have already been set, so there's no need to set them again
(however, property values should in general be set after only an object
is inserted). If they haven't been set, statements 2 - 4 should throw
a null exception.
If you have reqpriority, status, and reqtype objects, statements 2 - 4
should be:
reqpriority.addObjectToBothSidesOfRelationshipWithKey(req, "reqs");
status.addObjectToBothSidesOfRelationshipWithKey(req, "reqs");
reqtype.addObjectToBothSidesOfRelationshipWithKey(req, "reqs");
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.