I think I found the answer in a question you answered back in 2006...

prefetchingRelationshipKeyPaths is about pulling in all objects related to the object(s) being fetched. If you fetch the person and set prefetchingRelationshipKeyPaths to ("personNames", "personNames.publications") EOF will make three selects. One for Person, one for all PersonNames for that Person, and one for the Publications. The fetch will return the single person object.

Very nice!

Jeff

On Mar 6, 2009, at 9:55 PM, Jeff Schmitz wrote:


On Mar 6, 2009, at 7:05 PM, Chuck Hill wrote:

That is _batch_ fetching, not _pre_fetching. They do similar things, but prefetching is easier to use for most cases.

I'm working on the prefetching and was wondering, is there any way to prefetch several "layers" of relationships into the editing context all in one call? Or can you only go down one layer at a time?

Here's what I've come up with to prefetch all the entries in a pool, but I would like to be able to specify that all those entries Games also be pre-fetched (and so on):

public static Pool fetchPoolWithNameAndPrefetchEntries(EOEditingContext ec, String name, byte poolType) {
                
                EOQualifier poolQual = Pool.POOL_TYPE.eq(poolType).and(
                                Pool.NAME.likeInsensitive(name));
ERXFetchSpecification poolFetch = new ERXFetchSpecification(_Pool.ENTITY_NAME, poolQual, null); NSArray <String> keyPaths = new NSArray(new String[] {Pool.ENTRIES_KEY});
            poolFetch.setPrefetchingRelationshipKeyPaths(keyPaths);
return (Pool) ec.objectsWithFetchSpecification(poolFetch).lastObject();
        }

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/jeffandmonica%40mac.com

This email sent to [email protected]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to