Re: When (not) to use session().defaultEditingContext()
Re: When (not) to use session().defaultEditingContext()
- Subject: Re: When (not) to use session().defaultEditingContext()
- From: Ben Ketteridge <email@hidden>
- Date: Fri, 29 Oct 2004 11:00:47 +0100
On Fri, 29 Oct 2004 11:45:56 +0200, email@hidden
<email@hidden> wrote:
> I advocate creating fresh editing contexts as often as possible. I.e. each time you
> start a procedure that's logically independent of what was done previously. E.g.
> when the user submits a search query. The editing context gets carried on from
> there to the result list, the detail pages, ... but is not reused for another search.
> (Run a search for 'trails' on the webobjects-dev mailing list over at OmniGroup)
Your strategy is all very well if your transactions are truly
independent. However, we have a User object that lives in the Session
- it therefore lives in the defaultEditingContext. Hanging off the
User object are relationships that restrict the User to doing work for
particular Clients within the system. This Client is then used to
create Sales Orders - and all of a sudden we have to do work to make
sure that user interactions do calls to localInstanceOfObject all over
the code to ensure that we don't accidentally put the User's Client
(in the defaultEditingContext) into a relationship from a SalesOrder
(in a transaction-specific editingContext).
There is more to the decision on which editingContext you use that
simply stating 'always create a new one'. I would have to add the
caveat, 'where you're not depending on objects in another one.'
Ben
--
| Ben Ketteridge email@hidden, aka Gremlin |
| It is by caffeine alone that I set my mind in motion. |
| It is by the coffee that the thoughts acquire speed, |
| the lips acquire stains, the stains become a warning. |
| It is by caffeine alone that I set my mind in motion. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden