Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 93382 invoked from network); 9 Jun 2006 07:12:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jun 2006 07:12:07 -0000 Received: (qmail 49826 invoked by uid 500); 9 Jun 2006 07:12:07 -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 49815 invoked by uid 99); 9 Jun 2006 07:12:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jun 2006 00:12:07 -0700 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 [216.148.213.132] (HELO smtp.mailix.net) (216.148.213.132) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jun 2006 00:12:06 -0700 Received: from [192.168.8.8] (helo=localhost) by smtp.mailix.net with asmtp (Exim 4.24-MG) id 1Fob9h-0001mV-CQ; Fri, 09 Jun 2006 00:11:41 -0700 Received: from 80.223-201-80.adsl.skynet.be (80.223-201-80.adsl.skynet.be [80.201.223.80]) by webmail.jpox.org (IMP) with HTTP for ; Fri, 9 Jun 2006 00:11:41 -0700 Message-ID: <1149837101.44891f2d5228f@webmail.jpox.org> Date: Fri, 9 Jun 2006 00:11:41 -0700 From: Erik Bengtson To: JDO Expert Group , Apache JDO project References: <6DC3CBE5-203B-4DB0-AF08-4CBBCBA4B17E@SUN.com> In-Reply-To: MIME-Version: 1.0 User-Agent: Internet Messaging Program (IMP) 3.2.3 X-Originating-IP: 80.201.223.80 X-SA-Exim-Mail-From: erik@jpox.org Subject: RE: Behavior of projection queries (long) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-SA-Exim-Version: 3.1 (built Thu Oct 23 13:26:47 PDT 2003) X-SA-Exim-Scanned: No; Unknown failure X-uvscan-result: clean (1Fob9h-0001mV-CQ) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N More inline Quoting David Ezzio : > Hi Craig, > > Comments inline. > > David > > > > -----Original Message----- > From: Craig L Russell [mailto:Craig.Russell@Sun.COM] > Sent: Thu 6/8/2006 9:11 PM > To: JDO Expert Group; Apache JDO project > Subject: Behavior of projection queries (long) > > Javadogs, > > For the JDO maintenance release, we have to decide what the behavior > is for projection queries of various kinds of fields. [There are no > TCK tests for this behavior.] Consider this class: > > class Company { > int id; > String symbol; > Date incorporated; > BigDecimal revenues; > Set departments; > Locale hqLocale; > Integer empCount; > Address hqAddress; > } > > and these JDOQL queries: > > Collection dtos = execute this query: "SELECT new > DTOCompany(symbol, incorporated, revenues, departments, hqLocale, > empCount, hqAddress) FROM Company ORDER BY id" > This query will raise JDOUserException, Collection fields cannot be projected. > Collection cos = execute this query: "SELECT FROM Company > ORDER BY id" > > 1. Now, iterate the collections of dtos and cos. For each > corresponding result dto and co in the collection of results: > > For each of symbol, incorporated, revenues, departments, hqLocale, > empCount, and hqAddress: > > Does dto.symbol == co.symbol? > > *** > NO > I'm not sure if would be a good idea to take the SCO instance from the FCO or not. Maybe in pratical terms for users NOT, but logically YES. > Does dto.symbol.equals(co.symbol)? > > *** > YES > > 2. Now, suppose I change the mutable second class fields of the > instances I get from cos (the persistent instances). > > tx.begin(); > cos.incorporated.setTime(new Date().getMillis()); > tx.commit(); > > tx.begin(); > cos.departments.add(new Department()); > tx.commit(); > > tx.begin(); > cos.hqAddress.setState("CA"); > tx.commit(); > > Have I modified the company instance in the database in any of these > cases? > > *** > YES > > > 3.Now, suppose I change the mutable second class fields of the > instances I get from dtos (the holders for the field values of the > instances). > > tx.begin(); > dtos.incorporated.setTime(new Date().getMillis()); > tx.commit(); > > tx.begin(); > dtos.departments.add(new Department()); > tx.commit(); > > tx.begin(); > dtos.hqAddress.setState("CA"); > tx.commit(); > > *** > Maybe, but only if Address is a first class object. > > Have I modified the company instance in the database in any of the > cases? > > Here's a proposal to clarify the specification. > > If mutable second class fields are selected by a projection query, > the instances returned by the query are the instances of the owning > first class instance. Changes made to the results are reflected in > the database at transaction commit. There is no requirement that > immutable fields returned by a projection query are identical to > corresponding fields in cached instances. > > The implication is that a projection query that selects mutable > second class fields has the effect of instantiating the owning first > class instance and associating the mutable second class fields in the > query result with the owning first class instance. So selecting first > name, last name, age, and ssn returns only values not associated with > persistent instances. But selecting incorporated, departments, or > hqAddress will instantiate the first class instances and its default > fetch group. > > *** > I'm sure you have a very good reason in mind. Perhaps I missed it. > I see Craig's point, however as you point below it may be trick for users. Collections and maps fields cannot be projected, so we have only non set fields left and allowing them to affect the database would not be much benefit. > One the one side, I fail to see the virtues of this proposal. On the other > side, the whole point of projections is to avoid instantiating first class > objects (although the collections produced may be collections of first class > objects). Likewise, projected values should never be owned by first class > objects. > > The proposal adds yet another corner case that will confuse, snare, and > flabbergast application developers. > > In my opinion, the rule should always be: projected SCOs are never owned, > projected FCOs are always managed. Modifying unowned SCOs never has an > effect on the database. Modifying FCOs no matter how you get them always has > an effect if the tx commits (except for the well know corner case of > modifying just the unowned side of a bidirectional relationship). That's > what most developers would expect. > *** > > Craig > > Craig Russell > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo > 408 276-5638 mailto:Craig.Russell@sun.com > P.S. A good JDO? O, Gasp! > > > _______________________________________________________________________ > Notice: This email message, together with any attachments, may contain > information of BEA Systems, Inc., its subsidiaries and affiliated > entities, that may be confidential, proprietary, copyrighted and/or > legally privileged, and is intended solely for the use of the individual > or entity named in this message. If you are not the intended recipient, > and have received this message in error, please immediately return this > by email and then delete it. >