cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: commit all objects, temporary objects, POJO's, DTO
Date Wed, 27 Apr 2011 15:16:24 GMT
You're going to have to give us more information before we can
speculate on what's the best choice.   It may be that a combination of
several approaches make sense for your current project.

I've used a number of approaches in the past.   For example.....

On one struts project, I created a per-session data context but only
made changes to it per request.  At the end of every request, the data
context contained committed "read-only" objects.   The changes were
either committed or rolled back by the end of the request.   Similar
to your DTO approach , except that the persisted-between-request
values were persisted as separate items.

For a JSF project, I used a per-request data context, but serialized
all modified-but-uncommitted data objects and unserialized them to the
next per-request data context.   No DTO here -- the Cayenne Objects
were used at every layer.

What you do depends on how long you need to keep modified or cached
objects around (only one request (requeest scope), between requests
("page" scope), the lifetime of the session (session scope), the
lifetime of the application (application scope).

There's nothing stopping you from using a combination of choices.  For
some things, create a data context on demand.   For other things, use
a session-scoped data context.

On Wed, Apr 27, 2011 at 10:54 AM, felix
<> wrote:
> Thanks for your quick response.
> It seems like we have two options:
> - Create a context per writeable action (otherwise we could not retrieve an
> object, updated and save exactly when we want, in other words, when the obj
> is in a consistent state)
> - Create a DTO layer and have for instance one context per session. The most
> flexible option so far.
> I have heard there is something related to POJOs in Cayenne, Could I have
> more information regarding this point (I've tried but no much info on this)?
> Thanks a lot
> --
> View this message in context:
> Sent from the Cayenne - User mailing list archive at

View raw message