You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by ks...@apache.org on 2010/10/11 16:37:49 UTC

svn commit: r1021358 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/trans/ test/java/org/apache/cayenne/access/ test/java/org/apache/cayenne/testdo/testmap/ test/java/org/apache/cayenne/testdo/tes...

Author: kseniak
Date: Mon Oct 11 14:37:48 2010
New Revision: 1021358

URL: http://svn.apache.org/viewvc?rev=1021358&view=rev
Log:
CAY-1484. Fixed using of incorrect alias during the translation of the SelectQuery

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/CompoundPaintingLongNames.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/auto/_CompoundPaintingLongNames.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java?rev=1021358&r1=1021357&r2=1021358&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java Mon Oct 11 14:37:48 2010
@@ -364,6 +364,8 @@ public class SelectTranslator extends Qu
             }
 
             private void visitRelationship(ArcProperty property) {
+                resetJoinStack();
+                
                 ObjRelationship rel = property.getRelationship();
                 DbRelationship dbRel = rel.getDbRelationships().get(0);
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java?rev=1021358&r1=1021357&r2=1021358&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java Mon Oct 11 14:37:48 2010
@@ -33,6 +33,7 @@ import org.apache.cayenne.query.EJBQLQue
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.testdo.testmap.Artist;
 import org.apache.cayenne.testdo.testmap.CompoundPainting;
+import org.apache.cayenne.testdo.testmap.CompoundPaintingLongNames;
 import org.apache.cayenne.testdo.testmap.Gallery;
 import org.apache.cayenne.unit.CayenneCase;
 
@@ -183,6 +184,23 @@ public class DataContextFlattenedAttribu
         }
     }
 
+    /**
+     * Emulates the situation when flattened attribute has unusual(long) name,
+     *  that puts this attribute property to the top of PersistentDescriptor.declaredProperties map,
+     *  {@link PersistentDescriptor}[105]
+     *  
+     *  That forced an error during the building of the SelectQuery statement, CAY-1484
+     *  
+     */
+    public void testSelectCompoundLongNames() throws Exception {
+        populateTables();
+        SelectQuery query = new SelectQuery(CompoundPaintingLongNames.class);
+         // the error was thrown on query execution
+        List<?> objects = context.performQuery(query);
+        assertNotNull(objects);
+    }
+
+    
     public void testSelectEJQBQL() throws Exception {
         populateTables();
         EJBQLQuery query = new EJBQLQuery(

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/CompoundPaintingLongNames.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/CompoundPaintingLongNames.java?rev=1021358&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/CompoundPaintingLongNames.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/CompoundPaintingLongNames.java Mon Oct 11 14:37:48 2010
@@ -0,0 +1,7 @@
+package org.apache.cayenne.testdo.testmap;
+
+import org.apache.cayenne.testdo.testmap.auto._CompoundPaintingLongNames;
+
+public class CompoundPaintingLongNames extends _CompoundPaintingLongNames {
+
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/auto/_CompoundPaintingLongNames.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/auto/_CompoundPaintingLongNames.java?rev=1021358&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/auto/_CompoundPaintingLongNames.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/testmap/auto/_CompoundPaintingLongNames.java Mon Oct 11 14:37:48 2010
@@ -0,0 +1,110 @@
+package org.apache.cayenne.testdo.testmap.auto;
+
+import java.math.BigDecimal;
+
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.testdo.testmap.Artist;
+import org.apache.cayenne.testdo.testmap.Gallery;
+import org.apache.cayenne.testdo.testmap.PaintingInfo;
+import org.apache.cayenne.testdo.testmap.ROArtist;
+
+/**
+ * Class _CompoundPaintingLongNames was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _CompoundPaintingLongNames extends CayenneDataObject {
+
+    public static final String ARTIST_LONG_NAME_PROPERTY = "artistLongName";
+    public static final String ESTIMATED_PRICE_PROPERTY = "estimatedPrice";
+    public static final String GALLERY_LONG_NAME_PROPERTY = "galleryLongName";
+    public static final String PAINTING_DESCRIPTION_PROPERTY = "paintingDescription";
+    public static final String PAINTING_TITLE_PROPERTY = "paintingTitle";
+    public static final String TEXT_LONG_REVIEW_PROPERTY = "textLongReview";
+    public static final String TO_ARTIST_PROPERTY = "toArtist";
+    public static final String TO_ARTIST1_PROPERTY = "toArtist1";
+    public static final String TO_GALLERY_PROPERTY = "toGallery";
+    public static final String TO_PAINTING_INFO_PROPERTY = "toPaintingInfo";
+
+    public static final String PAINTING_ID_PK_COLUMN = "PAINTING_ID";
+
+    public void setArtistLongName(String artistLongName) {
+        writeProperty("artistLongName", artistLongName);
+    }
+    public String getArtistLongName() {
+        return (String)readProperty("artistLongName");
+    }
+
+    public void setEstimatedPrice(BigDecimal estimatedPrice) {
+        writeProperty("estimatedPrice", estimatedPrice);
+    }
+    public BigDecimal getEstimatedPrice() {
+        return (BigDecimal)readProperty("estimatedPrice");
+    }
+
+    public void setGalleryLongName(String galleryLongName) {
+        writeProperty("galleryLongName", galleryLongName);
+    }
+    public String getGalleryLongName() {
+        return (String)readProperty("galleryLongName");
+    }
+
+    public void setPaintingDescription(String paintingDescription) {
+        writeProperty("paintingDescription", paintingDescription);
+    }
+    public String getPaintingDescription() {
+        return (String)readProperty("paintingDescription");
+    }
+
+    public void setPaintingTitle(String paintingTitle) {
+        writeProperty("paintingTitle", paintingTitle);
+    }
+    public String getPaintingTitle() {
+        return (String)readProperty("paintingTitle");
+    }
+
+    public void setTextLongReview(String textLongReview) {
+        writeProperty("textLongReview", textLongReview);
+    }
+    public String getTextLongReview() {
+        return (String)readProperty("textLongReview");
+    }
+
+    public void setToArtist(Artist toArtist) {
+        setToOneTarget("toArtist", toArtist, true);
+    }
+
+    public Artist getToArtist() {
+        return (Artist)readProperty("toArtist");
+    }
+
+
+    public void setToArtist1(ROArtist toArtist1) {
+        setToOneTarget("toArtist1", toArtist1, true);
+    }
+
+    public ROArtist getToArtist1() {
+        return (ROArtist)readProperty("toArtist1");
+    }
+
+
+    public void setToGallery(Gallery toGallery) {
+        setToOneTarget("toGallery", toGallery, true);
+    }
+
+    public Gallery getToGallery() {
+        return (Gallery)readProperty("toGallery");
+    }
+
+
+    public void setToPaintingInfo(PaintingInfo toPaintingInfo) {
+        setToOneTarget("toPaintingInfo", toPaintingInfo, true);
+    }
+
+    public PaintingInfo getToPaintingInfo() {
+        return (PaintingInfo)readProperty("toPaintingInfo");
+    }
+
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml?rev=1021358&r1=1021357&r2=1021358&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/testmap.map.xml Mon Oct 11 14:37:48 2010
@@ -366,6 +366,14 @@
 		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
 		<obj-attribute name="textReview" type="java.lang.String" db-attribute-path="toPaintingInfo.TEXT_REVIEW"/>
 	</obj-entity>
+	<obj-entity name="CompoundPaintingLongNames" className="org.apache.cayenne.testdo.testmap.CompoundPaintingLongNames" clientClassName="test.client.CompoundPaintingLongNames" dbEntityName="PAINTING" superClassName="org.apache.cayenne.CayenneDataObject" clientSuperClassName="org.apache.cayenne.PersistentObject">
+		<obj-attribute name="artistLongName" type="java.lang.String" db-attribute-path="toArtist.ARTIST_NAME"/>
+		<obj-attribute name="estimatedPrice" type="java.math.BigDecimal" db-attribute-path="ESTIMATED_PRICE"/>
+		<obj-attribute name="galleryLongName" type="java.lang.String" db-attribute-path="toGallery.GALLERY_NAME"/>
+		<obj-attribute name="paintingDescription" type="java.lang.String" db-attribute-path="PAINTING_DESCRIPTION"/>
+		<obj-attribute name="paintingTitle" type="java.lang.String" db-attribute-path="PAINTING_TITLE"/>
+		<obj-attribute name="textLongReview" type="java.lang.String" db-attribute-path="toPaintingInfo.TEXT_REVIEW"/>
+	</obj-entity>
 	<obj-entity name="CompoundPkTestEntity" className="org.apache.cayenne.testdo.testmap.CompoundPkTestEntity" dbEntityName="COMPOUND_PK_TEST">
 		<obj-attribute name="key1" type="java.lang.String" db-attribute-path="KEY1"/>
 		<obj-attribute name="key2" type="java.lang.String" db-attribute-path="KEY2"/>
@@ -648,6 +656,10 @@
 	<obj-relationship name="toArtist" source="CompoundPainting" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
 	<obj-relationship name="toGallery" source="CompoundPainting" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
 	<obj-relationship name="toPaintingInfo" source="CompoundPainting" target="PaintingInfo" deleteRule="Cascade" db-relationship-path="toPaintingInfo"/>
+	<obj-relationship name="toArtist" source="CompoundPaintingLongNames" target="Artist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<obj-relationship name="toArtist1" source="CompoundPaintingLongNames" target="ROArtist" deleteRule="Nullify" db-relationship-path="toArtist"/>
+	<obj-relationship name="toGallery" source="CompoundPaintingLongNames" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>
+	<obj-relationship name="toPaintingInfo" source="CompoundPaintingLongNames" target="PaintingInfo" deleteRule="Nullify" db-relationship-path="toPaintingInfo"/>
 	<obj-relationship name="compoundFkArray" source="CompoundPkTestEntity" target="CompoundFkTestEntity" db-relationship-path="compoundFkArray"/>
 	<obj-relationship name="artistExhibitArray" source="Exhibit" target="ArtistExhibit" deleteRule="Cascade" db-relationship-path="artistExhibitArray"/>
 	<obj-relationship name="toGallery" source="Exhibit" target="Gallery" deleteRule="Nullify" db-relationship-path="toGallery"/>