Return-Path: Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: (qmail 8936 invoked from network); 9 Oct 2010 20:51:54 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Oct 2010 20:51:54 -0000 Received: (qmail 84469 invoked by uid 500); 9 Oct 2010 20:51:54 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 84453 invoked by uid 500); 9 Oct 2010 20:51:54 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 84445 invoked by uid 99); 9 Oct 2010 20:51:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Oct 2010 20:51:54 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 09 Oct 2010 20:51:48 +0000 Received: (qmail 20503 invoked from network); 9 Oct 2010 20:51:27 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 9 Oct 2010 20:51:27 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1081) Subject: Re: [jira] Updated: (CAY-1484) Flattened attribute queries are incorrectly generated From: Andrus Adamchik In-Reply-To: <15685967.41031286540615134.JavaMail.jira@thor> Date: Sat, 9 Oct 2010 23:51:26 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <25A39E21-6A10-4A99-BDDF-7A1FAD84BD12@objectstyle.org> References: <15685967.41031286540615134.JavaMail.jira@thor> To: dev@cayenne.apache.org X-Mailer: Apple Mail (2.1081) Hi Xenia, Thanks for looking into this. I reviewed the patch - looks correct to me = (the unit test fails with an error before changes to SelectTranslator, = and passes after doing the join stack reset), so please feel free to use = your new committer powers to apply it. A few notes: (1) Don't forget to add the newly generated = CompoundPaintingLongNames.java and _CompoundPaintingLongNames.java (not = included in the patch).=20 (2) I think we may even go with a more general fix - instead of = conditionally resetting the stack after a flattened attribute, always do = a reset before any attribute or relationship: diff --git = a/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ac= cess/trans/SelectTranslator.java b/framework/cayen index 4ddee21..0d1c64f 100644 --- = a/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ac= cess/trans/SelectTranslator.java +++ = b/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/ac= cess/trans/SelectTranslator.java @@ -364,6 +365,8 @@ public class SelectTranslator extends QueryAssembler = { } =20 private void visitRelationship(ArcProperty property) { + resetJoinStack(); + =20 ObjRelationship rel =3D property.getRelationship(); DbRelationship dbRel =3D = rel.getDbRelationships().get(0); The reset is a rather cheap operation, and the above seems to be just a = little more consistent (hmm... I wonder if not resetting it inside = 'visitRelationship' would result in bugs similar to CAY-1484 for = entities with multiple flattened relationships??) Andrus=20 On Oct 8, 2010, at 3:23 PM, Ksenia Khailenko (JIRA) wrote: >=20 > [ = https://issues.apache.org/jira/browse/CAY-1484?page=3Dcom.atlassian.jira.p= lugin.system.issuetabpanels:all-tabpanel ] >=20 > Ksenia Khailenko updated CAY-1484: > ---------------------------------- >=20 > Attachment: CAY-1484.-Fixed-using-of-incorrect-alias.patch >=20 >> Flattened attribute queries are incorrectly generated >> ----------------------------------------------------- >>=20 >> Key: CAY-1484 >> URL: https://issues.apache.org/jira/browse/CAY-1484 >> Project: Cayenne >> Issue Type: Bug >> Components: Core Library >> Affects Versions: 3.0.1 >> Environment: Gentoo linux >> MySQL 5.1 >> java version "1.6.0_20" >> Java(TM) SE Runtime Environment (build 1.6.0_20-b02) >> Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) >> Reporter: Misha Doronin >> Attachments: bugdemo_maven_derby.zip, = bugdemo_maven_derby_nobug.zip, = CAY-1484.-Fixed-using-of-incorrect-alias.patch, CayenneBugDemo.zip >>=20 >> Original Estimate: 1h >> Remaining Estimate: 1h >>=20 >> Attached eclipse project demonstrating issue, including cayenne model >> When creating database structure like: >> table1 >> t1key >> t1value >> t2keyref >> table2 >> t2key >> t2value >> t3keyref >> table3 >> t3key >> t3value >> and cayenne model with flattened attribute table3.t3value in table2 >> it produces incorrect join query to table2 and 3: >> SELECT t1.t3value, t1.t2key, t0.t2value, t0.t3keyref, t0.t2key FROM = testschema.table2 t0 JOIN testschema.table3 t1 ON (t0.t3key =3D = t1.t3keyref) WHERE t0.t2key =3D ? >> Note t1.t2key, which obviously shouldn't be there and produces error. >=20 > --=20 > This message is automatically generated by JIRA. > - > You can reply to this email to add a comment to the issue online. >=20 >=20