Am 06.09.2009 um 10:29 schrieb Chan Yeow Heong, Jerome:

So what happens after I do

nested.save();

This commits all changes of nested to original.

original.save();

This commits all changes of original to the data storage (mostly this will be the database).


Does nested go away? Does it get garbage collected?

If you don't hold any references to nested anymore then yes it will be garbage collected.

What is the editing context of the objects manipulated after both saves are done? Is it original?

You mean if there were additional changes in original (made outside of nested) are they reflected in nested? Looking at http://developer.apple.com/legacy/mac/library/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/WebObjects/Topics/ProgrammingTopics.39.html a nested editing context behaves as any other 'normal' one. A standard editing context doesn't see changes in the database unless it refetches its objects. So I would guess that the nested editing context doesn't see the changes that were made outside of it in the parent unless you 'refetch' them into it. But this is just a guess, I use nested editing contexts very rarely in special cases. A safe method would be to throw your old nested editing context away and create a new one after the save. As it doesn't have to make a roundtrip to the database which would cost time, it gets its objects from another editing context in memory which won't cause a noticeable delay.



On 05-Sep-2009, at 6:47 PM, Johann Werner wrote:

Hi Jerome,

Am 05.09.2009 um 11:50 schrieb Chan Yeow Heong, Jerome:

When I'm using nested editing contexts, do I need to call revert on a original editing context when I call revert on the nested context?


EOEditingContext original = ERXEC.newEditingContext(true);
EOEditingContext nested = ERXEC.newEditingContext(original,true);

... do some work ...


... something went wrong and we have to cancel all changes ...

nested.revert();
original.revert(); // <-- Is this second call needed?

No, this call is not needed. A nested editing context behaves as any other 'normal' editing context with the only difference that saving the context doesn't push your changes to the db but into the parent context. So either call revert on your nested context or just discard the context and replace it by a new one.

jw

_______________________________________________
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/jw%40oyosys.de

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