Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 12328 invoked from network); 24 Mar 2006 18:52:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Mar 2006 18:52:54 -0000 Received: (qmail 54590 invoked by uid 500); 24 Mar 2006 18:52: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 54579 invoked by uid 99); 24 Mar 2006 18:52:53 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Mar 2006 10:52:53 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [62.240.242.88] (HELO smtp.xcalia.com) (62.240.242.88) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Mar 2006 10:52:52 -0800 Received: from localhost ([127.0.0.1]) by diane with esmtp (Exim 4.52) id 1FMrOe-0001iP-6V; Fri, 24 Mar 2006 19:52:29 +0100 Received: from diane ([127.0.0.1]) by localhost (diane [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24810-09; Fri, 24 Mar 2006 19:52:27 +0100 (CET) Received: from [172.16.0.30] (helo=DELLZILLA) by diane with esmtpa (Exim 4.52) id 1FMrOc-0001hk-6d; Fri, 24 Mar 2006 19:52:27 +0100 Reply-To: From: "Matthew T. Adams" To: , "'JDO Expert Group'" Cc: "Craig Russell" Date: Fri, 24 Mar 2006 10:51:42 -0800 Organization: Xcalia Message-ID: <001a01c64f74$145abf50$1e0010ac@DELLZILLA> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <1143139648.4422ed4069919@webmail.jpox.org> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 Importance: Normal X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at xcalia.com X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: matthew.adams@xcalia.com Subject: RE: serialize Detachable instance for storage X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on diane X-Spam-Level: X-SA-Exim-Version: 4.2 (built Thu, 03 Mar 2005 10:44:12 +0100) X-SA-Exim-Scanned: Yes (on diane) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.7 required=5.0 tests=ALL_TRUSTED,AWL autolearn=failed version=3.0.4 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Erik, I now understand your issue. If you declare a PC class that is = detachable to also be serialized in another class, how do you prevent the = detachment algorithm from running when the instance is being = serialized/deserialized for the purposes of persistent storage versus being = serialized/deserialized for any other reason? After all, the desired behavior, I think, is to = store embedded serialized instances as they are in their current state, not in = a detached-clean or detached-dirty state. Here is an example that I think illustrates the issue: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D // Class foo.Person package foo; public class Person { protected Address address; // other fields... } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D // Class foo.Address package foo; public class Address { // fields... } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D // Some client code public void testPersistNewSerializedAddressInstance() { PersistenceManagerFactory pmf =3D JDOHelper.getPersistenceManagerFactory("pmf.properties"); pmf.setDetachAllOnCommit(true); PersistenceManager pm =3D pmf.getPersistenceManager(); pm.currentTransaction().begin(); Person person =3D new Person(); pm.makePersistent(person); Address address =3D new Address(); person.setAddress(address); pm.currentTransaction().commit(); // Q1: During storage, 'address' will be serialized, due to metadata requirement, and serialized objects are // implicitly detached according to spec section 12.6.8. Is the address stored in the database detached? In // other words, does the serialized form of the Address instance stored in the database contain detachment // information? // Q2: Does 'address' reference a detached instance now because = of serialization of Person.address? // Q3: Does 'person.address =3D=3D address' return true? } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D There are other scenarios that should probably be clarified as well, in particular, when an Address is loaded from the data store, it is deserialized. According to the spec, deserialized detached instances = are in one of the detached states (detached-clean, detached-dirty). Does that mean, then, that an Address deserialized from the data store is detached-clean or persistent-clean? --matthew >-----Original Message----- >From: Erik Bengtson [mailto:erik@jpox.org]=20 >Sent: Thursday, March 23, 2006 10:47 AM >To: JDO Expert Group; Apache JDO project >Subject: Re: serialize Detachable instance for storage > > >Hi Craig, > >> On Mar 17, 2006, at 11:40 AM, Erik Bengtson wrote: >> >> > Hi, >> > >> > If we serialize a detachable instance for storage, does it have the >> > detach state >> > populated? >> >> Yes. Regardless of whether it's currently managed or already >> detached, the detached state is part of the serialized state of the >> instance. >> >> > It is at least a waste of space. >> >> I don't understand how the detached state is wasted space. It >> contains information that's needed if the instance is in future >> attached to a persistence manager. >> > >Let me ask differently: say a class A { B b; // detachable and=20 >serialized=3D"true" >} > >When you store an instance of A with a ref to B, B is=20 >serialized with detached >flags, but there is no utility of adding detached flags during=20 >serialization of >B because its purpose is to store in the database. So IMO, we=20 >should not add >detached flags in serialized stored instances. > >So, it is a waste of space in the database. >