cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r705995 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/trans/SelectTranslator.java test/java/org/apache/cayenne/access/DataContextPrefetchQualifierOverlapTest.java
Date Sun, 19 Oct 2008 12:06:08 GMT
Author: aadamchik
Date: Sun Oct 19 05:06:07 2008
New Revision: 705995

URL: http://svn.apache.org/viewvc?rev=705995&view=rev
Log:
CAY-1025 Do something about to-many prefetch limitations

changing joint prefetches to use OUTER joins; some tests are broken as a result

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchQualifierOverlapTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java

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=705995&r1=705994&r2=705995&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
Sun Oct 19 05:06:07 2008
@@ -429,7 +429,7 @@
                 for (PathComponent<DbAttribute, DbRelationship> component : table
                         .resolvePath(dbPrefetch, getPathAliases())) {
                     r = component.getRelationship();
-                    dbRelationshipAdded(r, JoinType.INNER, null);
+                    dbRelationshipAdded(r, JoinType.LEFT_OUTER, null);
                 }
 
                 if (r == null) {

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchQualifierOverlapTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchQualifierOverlapTest.java?rev=705995&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchQualifierOverlapTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchQualifierOverlapTest.java
Sun Oct 19 05:06:07 2008
@@ -0,0 +1,74 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access;
+
+import java.util.List;
+
+import org.apache.art.Artist;
+import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.PrefetchTreeNode;
+import org.apache.cayenne.query.QueryChain;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.unit.CayenneCase;
+
+public class DataContextPrefetchQualifierOverlapTest extends CayenneCase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        deleteTestData();
+    }
+
+    public void testToManyOverlappingQualifier() {
+        QueryChain data = new QueryChain();
+        data.addQuery(new SQLTemplate(
+                Artist.class,
+                "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (1, 'A1')"));
+        data.addQuery(new SQLTemplate(
+                Artist.class,
+                "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME) VALUES (2, 'A2')"));
+        data
+                .addQuery(new SQLTemplate(
+                        Artist.class,
+                        "INSERT INTO PAINTING (PAINTING_ID, ARTIST_ID, PAINTING_TITLE) VALUES
(1, 1, 'ABC')"));
+        data
+                .addQuery(new SQLTemplate(
+                        Artist.class,
+                        "INSERT INTO PAINTING (PAINTING_ID, ARTIST_ID, PAINTING_TITLE) VALUES
(2, 1, 'ABD')"));
+        data
+                .addQuery(new SQLTemplate(
+                        Artist.class,
+                        "INSERT INTO PAINTING (PAINTING_ID, ARTIST_ID, PAINTING_TITLE) VALUES
(3, 1, 'ACC')"));
+
+        createDataContext().performGenericQuery(data);
+
+        SelectQuery query = new SelectQuery(Artist.class);
+        query.andQualifier(ExpressionFactory
+                .likeExp("paintingArray.paintingTitle", "AB%"));
+        query.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY).setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
+
+        List<Artist> result = createDataContext().performQuery(query);
+        assertEquals(1, result.size());
+
+        Artist a = result.get(0);
+        assertEquals(3, a.getPaintingArray().size());
+    }
+
+}



Mime
View raw message