Re: Question on editing contexts
Re: Question on editing contexts
- Subject: Re: Question on editing contexts
- From: Francis Labrie <email@hidden>
- Date: Tue, 20 Jul 2004 19:41:11 -0400
Hi,
Le 20 juil. 2004, ` 18:51, Steve Sharman a icrit :
> I've got what is probably quite a naive question on editing contexts.
>
> If an object A in my application automatically fetches an object B
> through a relationship (e.g. if A is Organisation, and B is Rooms, and
> there is a relationship A <-->> B, and I display a page which shows
> all the rooms for an organisation in a table within a WORepetition),
> are all of the B objects fetched automatically inserted into an
> editing context (the default one, I guess)?
If the "default one" for you means the session default editing context,
the answer is: not necessarily. Faults (i.e. relationships related
fetches) will be resolved through the entity's editing context (i.e.
<EOInstance>.editingContext()). So if your object A has been fetched
through the session editing context, then yes, faults will be resolved
through it as well.
> If so, can I make changes to one of the retrieved B objects using it's
> methods and save these changes by saving changes on the
> defaultEditingContext, or if not, do I have to explicitly insert the B
> that I want to change into the default editing context and then save
> it?
The safest way to save change made to your object B would be:
EOEditingContext editingContext;
editingContext = objectsB.editingContext().lock();
// Locking is required if the editing context is not the default
session one
editingContext.lock();
try {
editingContext.saveChanges();
} catch(Exception e) {
// Doh! It goes wrong while saving, must deal with that...
} finally {
editingContext.unlock();
} // finally
--
Francis Labrie
Saint-Bruno-de-Montarville, Quebec, Canada
_______________________________________________
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.