RE: When (not) to use session().defaultEditingContext()
RE: When (not) to use session().defaultEditingContext()
- Subject: RE: When (not) to use session().defaultEditingContext()
- From: <email@hidden>
- Date: Fri, 29 Oct 2004 11:45:56 +0200
- Thread-topic: When (not) to use session().defaultEditingContext()
Hi!
The default editing context would do best not to exist at all. It is just too tempting.
For one, one should NEVER use the default editing context to update values. (Not even using editing contexts nested in the default session editing context). The reasoning behind this is that stuff may get saved to the database unintentionally. Imagine doing a modification on one page and then deciding to drop it going off to another page. Another page may at a later time save changes in the default editing context for reasons of its own and end up saving the changes made earlier.
The default editing context also has a too long life span for those wanting fresh data. The object graph living whithin an editing context is essentially a cache - a clone of the data in the database. The faulting mechanism brings in data on an as needed basis. It will rely on existing objects wherever possible. Thus the size of your object graph grows over the life span of the editing context. And despite asking for freh objects from a fetch you may see those fresh objects having relationships to not so fresh ones.
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)
Pierre
-----Original Message-----
From: webobjects-dev-bounces+pierre.bernard=email@hidden
[mailto:webobjects-dev-bounces+pierre.bernard=email@hidden]On
Behalf Of Jake MacMullin
Sent: Friday, October 29, 2004 2:16 AM
To: WebObjects (Group)
Subject: When (not) to use session().defaultEditingContext()
Hi All,
I¹ve just been reading Chuck¹s book (I¹m enjoying it thanks) and have just
read the section where the different types of editing context are explained.
However, I¹m not really sure I fully understand the description of the
default editing context:
³This editing context has a long life span and is best reserved for values
needed over the lifetime of a sessionS²
Can anyone explain what the ramifications of the default editing context¹s
long life span are? Why does it matter that it has a long life and why does
this suggest that it should be reserved for OEspecial¹ values that hang
around for the whole session. What problems am I likely to run in to if I
only use the default editing context?
Regards,
Jake MacMullin
_______________________________________________
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
**********************************************************************
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
**********************************************************************
_______________________________________________
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