Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 17142 invoked from network); 9 Jun 2006 01:11:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jun 2006 01:11:28 -0000 Received: (qmail 47037 invoked by uid 500); 9 Jun 2006 01:11:28 -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 47016 invoked by uid 99); 9 Jun 2006 01:11:27 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 18:11:27 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.42.249] (HELO nwkea-pix-1.sun.com) (192.18.42.249) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jun 2006 18:11:26 -0700 Received: from d1-sfbay-01.sun.com ([192.18.39.111]) by nwkea-pix-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id k591B5LO021512 for ; Thu, 8 Jun 2006 18:11:05 -0700 (PDT) Received: from conversion-daemon.d1-sfbay-01.sun.com by d1-sfbay-01.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0J0K00H01IETXX00@d1-sfbay-01.sun.com> (original mail from Craig.Russell@Sun.COM) for jdo-dev@db.apache.org; Thu, 08 Jun 2006 18:11:05 -0700 (PDT) Received: from [192.168.0.10] (c-24-6-172-77.hsd1.ca.comcast.net [24.6.172.77]) by d1-sfbay-01.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0J0K00FJVJAGRP00@d1-sfbay-01.sun.com> for jdo-dev@db.apache.org; Thu, 08 Jun 2006 18:11:04 -0700 (PDT) Date: Thu, 08 Jun 2006 18:11:02 -0700 From: Craig L Russell Subject: Behavior of projection queries (long) Sender: Craig.Russell@Sun.COM To: JDO Expert Group , Apache JDO project Message-id: <6DC3CBE5-203B-4DB0-AF08-4CBBCBA4B17E@SUN.com> MIME-version: 1.0 X-Mailer: Apple Mail (2.750) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-20--290428351; micalg=sha1 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Apple-Mail-20--290428351 Content-Type: multipart/alternative; boundary=Apple-Mail-19--290428901 --Apple-Mail-19--290428901 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed 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" 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? Does dto.symbol.equals(co.symbol)? 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? 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(); 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. 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! --Apple-Mail-19--290428901 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 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<Department> departments;
Locale = hqLocale;
Integer=A0empCount;
Address = hqAddress;
}

and these JDOQL = queries:

Collection<DTOCompany> = dtos =3D execute this query: "SELECT new DTOCompany(symbol, = incorporated, revenues, departments, hqLocale, empCount, hqAddress) FROM = Company ORDER BY id"

Collection<Company> = cos =3D 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 =3D=3D co.symbol?
Does = dto.symbol.equals(co.symbol)?

2. Now, suppose I change = the mutable second class fields of the instances I get from cos (the = persistent instances).

tx.begin();
cos.inc= orporated.setTime(new = Date().getMillis());
tx.commit();

tx.begin();
cos.dep= artments.add(new Department());
tx.commit();

tx.begin();
cos.hqA= ddress.setState("CA");
tx.commit();

Have I modified the company = instance in the database in any of these cases?

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).
=A0
tx.begin();
dtos.incorporated.setT= ime(new Date().getMillis());
tx.commit();

tx.begin();
dtos.de= partments.add(new Department());
tx.commit();

tx.begin();
dtos.hq= Address.setState("CA");
tx.commit();

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.

=A0Craig

=

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!


= --Apple-Mail-19--290428901-- --Apple-Mail-20--290428351 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGUDCCAwkw ggJyoAMCAQICEB7Y7fLHmKoeHTUdbtYrvpAwDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMTI1RoYXd0ZSBQ ZXJzb25hbCBGcmVlbWFpbCBJc3N1aW5nIENBMB4XDTA1MTIxNTIxNDc0NFoXDTA2MTIxNTIxNDc0 NFowbDEQMA4GA1UEBBMHUnVzc2VsbDEUMBIGA1UEKhMLQ3JhaWcgTGFpcmQxHDAaBgNVBAMTE0Ny YWlnIExhaXJkIFJ1c3NlbGwxJDAiBgkqhkiG9w0BCQEWFUNyYWlnLlJ1c3NlbGxAU3VuLkNPTTCC ASIwDQYJK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