Re: EO Changes Not Saving to DB?
Re: EO Changes Not Saving to DB?
- Subject: Re: EO Changes Not Saving to DB?
- From: Kieran Kelleher <email@hidden>
- Date: Mon, 24 May 2004 11:56:54 -0400
Pierre,
That definitely changed the sequence of events. EOF issued a SELECT
immediately upon calling committedSnapshotForObject(failedEO). And then
the
failedEO.reapplyChangesFromDictionary(valuesInFailedSave);
executed afterward.
Then when I saved, the EC did not recognise the EO as having changes
that needed to be saved, so it did not write it back out to the DB
after reapplying changes from dictionary. It did save another related
EO, but not the one that was faulted and revised. So it seems like the
reapplyChangesFromDictionary fails to flag the EO as needing to be
saved.
Is there a way to flag the EO as needing to be saved (force the save)
..... I can't seem to find a method in the API for that?
-Kieran
On May 24, 2004, at 11:01 AM, email@hidden wrote:
> Hi!
>
> try adding
>
> defaultEditingContext().committedSnapshotForObject(failedEO);
>
> right after
>
> defaultEditingContext().refaultObject(failedEO);
>
> If this helps, your problem is most likely connected to bug #3389369 -
> EOEditingContext.refreshObject() breaks object observing mecanism
> In which case you could bug email@hidden about fixing this.
>
> Regards
> Pierre
>
> -----Original Message-----
> From: email@hidden
> [mailto:email@hidden]On Behalf Of Kieran
> Kelleher
> Sent: Monday, May 24, 2004 4:14 PM
> To: WebObjects
> Subject: EO Changes Not Saving to DB?
>
>
> I want to handle an optimistic lock exception by refreshing the EO from
> the database and reapplying the new field values that the user had
> entered just before they had attempted to save (essentially merging the
> updated values with the latest db values into the current editing
> context and saving that merged version). The sequence of events is
> working well except that the last step using the ec's saveChanges
> method is not firing the fault and generating the SQL output. Here is
> what I am doing..........
>
> The chain of events begins when the user submits a form and an
> optimistic locking exception is thrown since the db values have been
> changed by a different instance of the application.
> // after catching and determining I have an optimistic locking
> exception, I successfully retrieve the updated attributes from the
> failed EO
> NSDictionary valuesInFailedSave = adaptorOperation.changedValues();
>
> // later, I refault the EO
> defaultEditingContext().refaultObject(failedEO);
>
> // next I reapply the updated values to the failedEO. I think this is
> where the problem is because watching the EOAdaptor Debug log, this
> statement does not immediately retrieve the db values and apply the
> dictionary values?? Should it not?
> failedEO.reapplyChangesFromDictionary(valuesInFailedSave);
>
> // finally I call
> defaultEditingContext().saveChanges();
>
> // ........... and nothing happens!
>
> Next the app displays the EO in a new page (save confirmation) and then
> EOF fires the fault, selects the latest values and applies the changes
> and the desired "merged" EO is correctly displayed!! The only problem
> is it never got saved. It seems the fault does not get fired as a
> result of the reapplyChangesFromDictionary and the saveChanges methods
>
> Any ideas?
>
> -Kieran
>
>
>
> ___________________________________
> Kieran Kelleher
> SmartleadsUSA,LLC
> 2656 West Lake Rd
> Palm Harbor, FL 34684
> email@hidden
> 727-785-0766 x33
> _______________________________________________
> 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.
>
>
>
> **********************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or entity to whom they are addressed.
> If you have received this email in error please notify the sender
> of this message. (email@hidden)
> This email message has been checked for the presence of computer
> viruses; however this protection does not ensure this message is
> virus free.
> Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
> **********************************************************************
_______________________________________________
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.