Re: Setting a Default toOne Relationship
Re: Setting a Default toOne Relationship
- Subject: Re: Setting a Default toOne Relationship
- From: Paul Lynch <email@hidden>
- Date: Fri, 19 May 2006 09:48:51 +0100
On 18 May 2006, at 18:25, Ken Anderson wrote:
Besides calling the set method in awakeFromInsertion(), I can't
imagine what else there is to do. Of course, you need to get the
EO in the correct editing context. Since the EC is passed into the
awakeFromInsertion() method, you could:
public void awakeFromInsertion(EOEditingContext ec) {
MyObject obj = EOUtilities.objectMatchingKeyandValue(ec, "ENTITY",
"KEY", "VALUE");
setRelObj(obj);
}
One catch that I have found with this approach is that, if you create
a local instance of the object in a different editing context, the
related object is still in the old ec, assuming that you haven't
first saved the record with the updated relationship and refaulted
the objects. I don't see how this can be avoided, or even if you
should attempt to avoid it.
Paul
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden