Re: How can I cast a NSMutableDictionary to a EOEnterpriseObject

Chuck Hill <[email protected]> Wed, 19 Nov 2008 13:52:57 -0800
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
On Nov 19, 2008, at 1:36 PM, Mike Schrag wrote:

>>>>> All objectWithRawRow does is to extract the PK and then calls  
>>>>> faultWithPrimaryKey() (IIRC).  So if the EO has not been fetched  
>>>>> and cached, this goes back to the database.
>>>>
>>>> Really?
>>>
>>> No, it calls ec.faultForRawRow(row, entityName)
>>> which calls ec.faultForRawRow(row, entityName, this)
>>> which calls objectstore.faultForRawRow(row, entityName, ec)...
>>
>> which extracts the GID and calls   
>> editingContext.faultForGlobalID(gid, editingContext);
>>
>> Slightly different call path than I recalled, but the same effect.
> Yeah, the important part is "not been fetched and cached".  It  
> creates a fault for the GID of the raw row.  If that GID is in the  
> snapshot cache, you will not hit the db, but if you just did a raw  
> row query against your db and got a bunch of rows back that have not  
> been cached in the snapshot cache, it will do a second database hit  
> to fill in the snapshot even if the raw row dictionary you have  
> represents exactly what it would pull in that second query.  This  
> was the point of my earlier gripe, actually.


Exactly.  Out of curiosity, how often do you do raw row fetches of all  
of the attributes?  Most of the time, I am only fetching a small sub- 
set.  That usage pattern may have been the original intention and why  
no attempt was made to populate the snapshot cache.  That said, this  
does seem like a very useful optimization.

Chuck

-- 
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.
http://www.global-village.net/products/practical_webobjects