Re: Filtering array returned by an EO's relationship (D2J)
Re: Filtering array returned by an EO's relationship (D2J)
- Subject: Re: Filtering array returned by an EO's relationship (D2J)
- From: Chuck Hill <email@hidden>
- Date: Tue, 28 Oct 2003 20:46:32 -0800
Hi Ray,
At 12:30 PM 29/10/2003 +1300, Ray Ackland wrote:
>On Wednesday, Oct 29, 2003, at 07:34 Pacific/Auckland, Ricardo Strausz
>wrote:
>
>> Did you try dataSource.setAuxiliaryQualifier(aQualifier);
>
>I had been reading up about that on the weekend. Don't know about most
>people, but I find I need to read the documentation a couple of times,
>do heaps of experiments to get something going, then read the doc's a
>few more times to cement the ideas.
>
Yeah, that sounds about right. :-)
>My current stage is replacing the standard call for storedValueForKey()
>with a specific objectsWithFetchSpecification() using the desired
>target entity, and qualifiers for the related record I am calling from,
>along with my filter qualifier.
>
I'm not sure I understand. If you are adding a new method to do this, then
OK. If you are replacing a generated method (representing a relationship
in the EOModel) that uses storedValueForKey(), well then you are asking for
grief and EOF will eventually give it to you. Pick a different method name.
>Seems to work, and only requests the
>objects I want (rather than getting all first and then filtering). I
>also have put in a conditional that the NSArray I am fetching into is
>null so I don't repeatedly do the fetch.
>
Sounds like a good optimization if...
>My only concerns are that I may be missing out on some WO magic, such
>as the fetched array being refreshed (seems ok in testing though) and
>that the EOEditingContext recognises the relationship between the
>source and destination objects.
>
... you make sure to null this array out when things change. With a
regular WO app and attributes this is not too much of a problem. Caching a
to-many relationship makes it much harder and I've no idea what oddities
D2JC might throw into the mix.
If you are not using the default editing context and creating new editing
contexts on a form by form basis you will probably be OK with what you are
doing. Otherwise, imagine object A caching part of its to-many
relationship B. One of the B objects changes and because of that change
should be added to or removed from the cached array. Object A has not
changed so no methods are going to get called on it that would allow you to
release the cached values. You will also have to contend with objects
being added to or removed from the B relationship. All of this situations
may occur in the same and other editing contexts.
Catching notifications is probably the best way to go about it. See the
EOEditingContext docs for relevant notifications.
Chuck
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
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.