Return-Path: Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: (qmail 22337 invoked from network); 20 Dec 2005 22:05:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Dec 2005 22:05:01 -0000 Received: (qmail 21465 invoked by uid 500); 20 Dec 2005 22:05:01 -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 21454 invoked by uid 99); 20 Dec 2005 22:05:01 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2005 14:05:01 -0800 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.98.36] (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Dec 2005 14:05:00 -0800 Received: from fe-amer-03.sun.com ([192.18.108.177]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id jBKM4eD7008659 for ; Tue, 20 Dec 2005 15:04:40 -0700 (MST) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0IRT00C01H7XEF00@mail-amer.sun.com> (original mail from Craig.Russell@Sun.COM) for jdo-dev@db.apache.org; Tue, 20 Dec 2005 15:04:40 -0700 (MST) Received: from [129.145.133.145] by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0IRT000MRHBRN900@mail-amer.sun.com> for jdo-dev@db.apache.org; Tue, 20 Dec 2005 15:04:39 -0700 (MST) Date: Tue, 20 Dec 2005 14:04:37 -0800 From: Craig L Russell Subject: Issue 150: Consistency requirements for relationships with mapped-by Sender: Craig.Russell@Sun.COM To: JDO Expert Group , Apache JDO project Message-id: <71E343BA-982A-47B1-9AF0-33E03432A0A3@Sun.COM> MIME-version: 1.0 X-Mailer: Apple Mail (2.746.2) Content-type: multipart/signed; protocol="application/pkcs7-signature"; boundary=Apple-Mail-55-42771486; 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-55-42771486 Content-Type: multipart/alternative; boundary=Apple-Mail-54-42770902 --Apple-Mail-54-42770902 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Javadogs, In chapter "15.3 Relationship Mapping" of the spec, "changes to the field mapped via mapped-by are not reflected in the datastore". However, this conflicts with the text that follows: "... the column(s) will be changed during commit and will therefore be visible by both sides in the next transaction.". I believe that the second part is more important than the first part. Specifically, if the user makes a change to a persistent field, at flush or commit time it makes sense to me that the implementation should make sure that the change is flushed to the datastore. Further, the spec says that changes will be visible by both sides in the next transaction, which has implications for RetainValues. I think it's technically feasible for changes to either side to be reflected in the database, and for RetainValues to be handled consistently. If two relationships (one on each side of an association) are mapped to the same column, the field on only one side of the association needs to be explicitly mapped. The field on the other side of the relationship can be mapped simply by using the mapped-by attribute identifying the field on the side that defines the mapping. Regardless of which side changes the relationship, flush (whether done as part of commit or explicitly by the user) will modify the datastore to reflect the change. There is no further relationship implied by having both sides of the relationship map to the same database column(s). In particular, making a change to one side of the relationship does not imply any runtime behavior by the JDO implementation to change the other side of the relationship in memory prior to flush and will therefore be visible by both sides in the next transaction. If the RetainValues flag or DetachAllOnCommit is set to true, and the relationship field is loaded, then the implementation will change the field on the other side so it is visible after transaction completion. Conflicting changes to relationships cause a JDOUserException to be thrown at flush time. Conflicting changes include: adding a related instance with a single-valued mapped-by relationship field to more than one one-to-many collection relationship setting both sides of a one-to-one relationship such that they do not refer to each other 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-54-42770902 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 Javadogs,

In chapter = "15.3 Relationship Mapping" of the spec, "changes to the field mapped = via mapped-by are not reflected in the datastore".

However, this conflicts with the text that = follows:

=A0"... the = column(s) will be changed during commit and will therefore be visible by = both sides in the next transaction.".

I believe = that the second part is more important than the first part. = Specifically, if the user makes a change to a persistent field, at flush = or commit time it makes sense to me that the implementation should make = sure that the change is flushed to the datastore. Further, the spec says = that changes will be visible by both sides in the next transaction, = which has implications for RetainValues.

I think it's = technically feasible for changes to either side to be reflected in the = database, and for RetainValues to be handled consistently.

<proposed 15.3>
If two relationships = (one on each side of an association) are mapped to the same column, the = field on only one side of the association needs to be explicitly = mapped.
The field on the other side of the relationship can be = mapped simply by=A0using the mapped-by attribute=A0identifying the field = on the side that defines the mapping. Regardless of which side changes = the relationship, flush (whether done as part of commit or explicitly by = the user) will modify the datastore to reflect the change. There is no = further relationship implied by having both sides of the relationship = map to the same database column(s). In particular, making a change to = one side of the relationship does not imply any runtime behavior by the = JDO implementation to change the other side of the relationship in = memory prior to flush=A0and will therefore be visible by both sides in = the next transaction. If the RetainValues flag or DetachAllOnCommit is = set to true, and the relationship field is loaded, then the = implementation will change the field on the other side so it is visible = after transaction completion.
Conflicting changes to = relationships cause a JDOUserException to be thrown at flush time. = Conflicting changes include:=A0
adding a related instance with = a single-valued mapped-by relationship field to more than one = one-to-many collection relationship
setting both sides of a = one-to-one relationship such that they do not refer to each = other
</proposed 15.3>


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-54-42770902-- --Apple-Mail-55-42771486 Content-Transfer-Encoding: base64 Content-Type: application/pkcs7-signature; name=smime.p7s Content-Disposition: attachment; filename=smime.p7s MIAGCSqG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