Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 56639 invoked from network); 21 Aug 2008 14:10:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Aug 2008 14:10:55 -0000 Received: (qmail 97558 invoked by uid 500); 21 Aug 2008 14:10:53 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 97536 invoked by uid 99); 21 Aug 2008 14:10:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Aug 2008 07:10:53 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of joerg.von.frantzius@artnology.com designates 80.67.29.23 as permitted sender) Received: from [80.67.29.23] (HELO smtprelay09.ispgateway.de) (80.67.29.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Aug 2008 14:09:54 +0000 Received: from [195.143.217.178] (helo=kali.berlin.artnology.com) by smtprelay09.ispgateway.de with esmtpa (Exim 4.68) (envelope-from ) id 1KWArl-0000KD-Hf; Thu, 21 Aug 2008 16:10:22 +0200 Message-ID: <48AD77AA.5090308@artnology.com> Date: Thu, 21 Aug 2008 16:11:54 +0200 From: Joerg von Frantzius User-Agent: Thunderbird 2.0.0.16 (X11/20080720) MIME-Version: 1.0 To: jdo-user@db.apache.org CC: Apache JDO project Subject: Re: Updating datastore with transient instance References: In-Reply-To: X-Enigmail-Version: 0.95.7 Content-Type: multipart/mixed; boundary="------------000309000901070100050201" X-Df-Sender: 383542 X-Virus-Checked: Checked by ClamAV on apache.org --------------000309000901070100050201 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, the use-case sounds very reasonable to me, e.g. when the implementation of a web-service sends out a serialized persistent object, receives back the object with changes, and now needs to apply the changes to the database. Since makePersistent() is handling attaching so far, this could be the place to transition such an object from transient to persistent-dirty (with all fields marked dirty). Maybe an exception should be thrown when there already is a persistent-dirty object with the same id managed by the same PM. Since that would mean change of behaviour (somebody might rely on inserting new objects when calling makePersistent() on transient instances that have an id value), there probably should be an additional setMergeOnMakePersistent(boolean) or something like that, defaulting to the old behaviour. This would only work for application-identity. For datastore-identity, some new method(s) would be required to determine the objects' ids, as Pavel suggested. Regards, Jörg Pavel wrote: > Hi, > > This email is a continuation of discussion started at > http://www.jpox.org/servlet/forum/viewthread?thread=4893&lastpage=yes . > > Quick summary is that there is a number of [I believe fairly strong] cases > where application deals with transient objects which somehow correspond to > already persisted objects. > > These instances have updated state in there, but persisting that state takes > extra code and datastore hits, just to preload persistent counterpart and > copy properties. > > My question is whether it is possible and makes sense for JDO to support > "attachment" of transient objects, so that > a) all the steps required for such "attachment" become duty of JDO > implementation, not client code and > b) reads before update are optimized (e.g. one read for collection) or > eliminated at all. > > Code-wise I imagine methods like > > // Application identity > T attachTransient(T instanceWithAppIdentity); > Collection attachTransientAll(Collection > instancesWithAppIdentity); > > // Datastore identity - client code provides id explicitly to let JDO > identify persistent counterpart > T attachTransient(T instanceWithDSIdentity, Object id); > Map attachTransientAll(Map > instancesWithDSIdentity); // Map is {id => instance} > > What do you think? > > Thanks, > Pavel > > -- ____________________________________________________________________ artnology GmbH - Milastraße 4 - 10437 Berlin - Germany Geschäftsführer: Ekkehard Blome (CEO), Felix Kuschnick (CCO) Registergericht: Amtsgericht Berlin Charlottenburg HRB 76376 UST-Id. DE 217652550 --------------000309000901070100050201--