Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C816C2FBC for ; Wed, 27 Apr 2011 16:33:54 +0000 (UTC) Received: (qmail 47548 invoked by uid 500); 27 Apr 2011 16:33:54 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 47522 invoked by uid 500); 27 Apr 2011 16:33:54 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 47514 invoked by uid 99); 27 Apr 2011 16:33:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Apr 2011 16:33:54 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.214.43] (HELO mail-bw0-f43.google.com) (209.85.214.43) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Apr 2011 16:33:49 +0000 Received: by bwz14 with SMTP id 14so2475829bwz.16 for ; Wed, 27 Apr 2011 09:33:27 -0700 (PDT) Received: by 10.204.151.202 with SMTP id d10mr250187bkw.168.1303922007665; Wed, 27 Apr 2011 09:33:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.85.4 with HTTP; Wed, 27 Apr 2011 09:33:07 -0700 (PDT) In-Reply-To: <1303907767164-2870230.post@n3.nabble.com> References: <1303907767164-2870230.post@n3.nabble.com> From: Michael Gentry Date: Wed, 27 Apr 2011 12:33:07 -0400 Message-ID: Subject: Re: commit all objects, temporary objects, POJO's, DTO To: user@cayenne.apache.org Content-Type: text/plain; charset=ISO-8859-1 Hi Felix, I use DataContexts to group related changes. If I need to do an unrelated change, I create a new (or child) DataContext, do my change in it, and commit it. You don't have to stick to just one DataContext. Create as many as you need. mrg On Wed, Apr 27, 2011 at 8:36 AM, felix wrote: > I am using Cayenne with Wicket, and am using the servlet filter described > here > > http://cayenne.apache.org/doc30/web-applications.html > > to bind a DataContext to requests. I understand this occurs per session, so > subsequent > requests within the session are associated to the same DataContext, which is > fine. > > However, If I understand correctly, doing a commit against a DataContext > will persist _all_ > objects associated to that context. If for instance, I am using Cayenne > objects to accumulate > data, but I do not want to persist these objects (eg because they have not > reached a consistent > state) but I _do_ want to save some other object, then calling commit to > save this latter object will > save everything, including data that was not ready to be persisted. > > I am not sure exactly what pattern I should be using with Cayenne. Should > Cayenne objects be exposed > beyond the persistent layer? I am considering using a Data Transfer Object > pattern, whereby Cayenne > objects only exist at the data layer, and data is exposed to the rest of the > application via > data transfer objects, which are a parallel structure of POJO's. In the case > of Wicket, this has > the additional benefit of solving potential problems with serialization that > may have been a problem > with Cayenne objects. > > So, in summary, what is the correct usage of Cayenne? Is the DTO pattern I > have mentioned a reasonable > approach? > > If DTO is a good path, should I be using the 'cgen' maven task to generate > POJO's? I have searched for > suitable velocity templates to be used with the 'cgen' task but have found > none. Should I write my own > or is something planned within the Cayenne project along these lines? > > -- > View this message in context: http://cayenne.195.n3.nabble.com/commit-all-objects-temporary-objects-POJO-s-DTO-tp2870230p2870230.html > Sent from the Cayenne - User mailing list archive at Nabble.com. >