You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by "Weddle, Anthony" <An...@bluescopesteel.com> on 2009/05/05 00:33:51 UTC

RE: Best Practices Question

Wouldn't it be better to use a nested context for "edit mode"? Once
committed, those changes would be visible in the shared context.

Tony

-----Original Message-----
From: Aristedes Maniatis [mailto:ari@ish.com.au] 
Sent: Wednesday, 22 April 2009 12:32 p.m.
To: user@cayenne.apache.org
Subject: Re: Best Practices Question


On 22/04/2009, at 6:40 AM, Ylan Segal wrote:

> In a web app where each session has a DataContext, do I need to  
> worry about data caching in different DataContexts?

I'd like to add just one further point. It is a common design pattern  
to create one read-only 'shared' context which is used to fetch and  
display information. This shared context lives for the life of the  
application. Then when users 'go into edit mode' whatever that means  
for your application, you create a new context for them and manage  
their changes until they save in that dedicated context.

You need to be careful because you cannot relate two objects in  
different contexts, but it isn't hard to copy objects from one context  
to another.

There is nothing in Cayenne which enforces a context read-only or  
'shared', it is just the manner in which you use it.

Regards
Ari