Re: refreshRefetchedObjects
Chuck Hill <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.wonder-disc |
|---|---|
| Message-ID | <[email protected]> |
On 2013-03-08, at 4:11 PM, Ramsey Gurley wrote:
> On Mar 8, 2013, at 4:33 PM, Chuck Hill wrote:
> On 2013-03-08, at 3:13 PM, Ramsey Gurley wrote:
>>> On Mar 8, 2013, at 3:40 PM, Chuck Hill wrote:
>>> On 2013-03-08, at 2:30 PM, Ramsey Gurley wrote:
>>>>> On Mar 8, 2013, at 3:21 PM, Ramsey Gurley wrote:
>>>>>> On Mar 8, 2013, at 3:07 PM, Chuck Hill wrote:
>>>>>>> On 2013-03-08, at 2:02 PM, Ramsey Gurley wrote:
>>>>>>>>
>>>>>>>> So I'm reading EOFetchSpec's javadoc for refreshing on fetch and I see:
>>>>>>>>
>>>>>>>> "For example, suppose that an employee object is fetched and then refetched, without changing the employee between fetches. In this case you want to refresh the employee when you refetch it because another application might have updated the object since the first fetch. To keep the employee in sync with the employee data in the external repository you would need to replace the employee's outdated values with the new ones. On the other hand, if you have to fetch the employee, change it, and then refetch it, you would not want to refresh the employee. If you are to refresh it whether or not another application had changed the employee you would lose the changes that you have made to the object."
>>>>>>>>
>>>>>>>> However when I actually try this in Freshness Explorer, that is not what happens. If I fetch John Smith, change his name to Travis, then submit and [Fetch One EO] with the [x]refresh checkbox checked, it stays Travis in the EC.
>>>>>>>>
>>>>>>>> It seems rather silly to go to the database, fetch rows, and then ignore those fresh values in favor of some stale snapshots hanging around. :-/
>>>>>>>
>>>>>>> You prefer to erase the user's unsaved changes?
>>>>>>
>>>>>> That's the thing, it doesn't erase the changes. The changes stay in place and only the values the user hasn't touched get updated (assuming they changed).
>>>>
>>>> Yes, that is exactly what the documentation states:
>>>>
>>>>>>>> if you have to fetch the employee, change it, and then refetch it, you would not want to refresh the employee. If you are to refresh it whether or not another application had changed the employee you would lose the changes that you have made to the object.
>>>>
>>>>
>>>>> I have a copy of Freshness Explorer here if you want to see what I mean
>>>>
>>>> I know how it works. :-) Maybe it is just Friday, but you seem to be complaining that the behaviour matches the documention.
>>>
>>> Either I'm reading it wrong, or the behavior doesn't match the documentation. I don't know if the list allows 3.4MB mov attachments, but have a look:
>>
>> What that movie shows, matches what the documentation states. If you do a fetch that does not refresh, any existing snapshots are not updated AT ALL. Regardless. The fetched data is discarded.
>
>
> Which is the behavior I find odd for the default.
Odder than having concurrent dispatch off by default? Likely the original fetch spec implementation ever refreshed so when they added this, they kept the default as being no change in behaviour. That is hardly unusual in WO. ;-)
>> If you do a fetch that DOES refresh, the SNAPSHOT is updated with fresh data from the database. Then the database snapshot is merged into the snapshot in the EC. If any data has been modified locally in the EC, then the user modified value takes priority over the fresh data from the database ("you would not want to refresh the employee. If you are to refresh it whether or not another application had changed the employee you would lose the changes").
>
>
> I think that's the part I found confusing. I thought it was stating that the snapshot would overwrite changes in the ec, which clearly wasn't the case.
>
>
>> That is the default behaviour.
>
>
> The default for refreshesRefetchedObjects is false. Why? That's what doesn't make any sense to me. When is that behavior ever desirable?
>
>
>> If you want to discard user changes, then you either need to call revert() on the EC prior to doing the refreshing fetch OR you need to implement that EC delegate method to tell the EC to discard the user modified data and use the snapshot data instead.
>>
>>
>> Chuck
>
> I want to keep the changes. But I want to keep the fresh data whenever I go to the database too. I only went to the javadocs trying to find an explanation for the default being false. I think I'll go add
>
> 9001: *true* => refreshesRefetchedObjects = 'true' [BooleanAssignment]
>
> to my rule file now. I just wanted to know if there was some corner case where that would be a bad idea :-)
Just performance.
--
Chuck Hill
Executive Managing Partner, VP Development and Technical Services
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/gvc/practical_webobjects
Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev