Re: Fetch Spec Question
Re: Fetch Spec Question
- Subject: Re: Fetch Spec Question
- From: Jonathan Rochkind <email@hidden>
- Date: Wed, 21 Jan 2004 17:02:55 -0600
An EOFetchSpecification, passed to
someEditingContext.objectsWithFetchSpecification() will _always_ go
to the database. There will always be a round trip to the db
triggered.
Now, the _attributes_ of the values returned may be ignored
completely, depending on the status of the EODatabase snapshots, how
the fetch spec is configured (see refreshesRefetchedObjects), and
other EOF stack settings. It can be a sometimes confusing issue. And
within an EOEditingContext, uniqueing is enforced---only one object
can exist within a given EC representing a specific row in te db.
But _which_ EOs are returned from objectsWithFetchSpecification
(rather than the values of those EOs, neccesarily) will be determined
by a round trip to the db, always, guaranteed.
If you have the primary key value(s) of the object(s) you are
interested in, you may find EOUtilities.faultWithPrimaryKeyValue() of
use. This will return a 'fault' object, when, when accessed, will
take a trip to the db only when neccesary---if the object in question
already exists in the EC, no trip to the db is neccesary to retrieve
it. But if you create a bunch of 'faults' like this, you are
potentially opening up yourself to one db trip _per fault_, when you
could have gotten a bunch of objects in a single db trip with an
ordinary fetch spec.
Beyond faulting.... I think it's probably up to you to write your
own caching system, if you want to get objects from memory when
you've got them in memory, and go to the db only when neccesary. I
can't think of anything built in to facillitate this, but maybe I'm
not thinking of something.
--Jonathan
At 3:47 PM -0600 1/21/04, james cicenia wrote:
Hello -
If I have created 12 fetch specifications with different criteria
for the same object will it still go to the database or will
it be smart enough to know that it already has the objects
in memory that match the criteria?
Sincerely,
James Cicenia - President/CEO
cell: 773.398.4649
www.jimijon.com
~~~~~~
The Internet's only Weekly Video Horoscope!
http://absinthium.jimijon.com
_______________________________________________
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.
_______________________________________________
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.