cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r899283 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/ framework/...
Date Thu, 14 Jan 2010 16:42:53 GMT
Author: aadamchik
Date: Thu Jan 14 16:42:52 2010
New Revision: 899283

URL: http://svn.apache.org/viewvc?rev=899283&view=rev
Log:
CAY-952 Generate OUTER joins for flattened attributes in a SelectQuery

Patch by Ksenia Khailenko. Changes to EJBQLJoinAppender are actually related to another issue:
CAY-1069

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLJoinAppender.java
    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

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=899283&r1=899282&r2=899283&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Thu Jan 14 16:42:52 2010
@@ -13,6 +13,7 @@
 ----------------------------------
 Changes/New Features Since 3.0:
 
+CAY-952 Generate OUTER joins for flattened attributes in a SelectQuery
 CAY-1251 Memorize user-selected column widths in preferences
 CAY-1310 Remove everything deprecated in 3.0
 CAY-1314 Migrate Modeler Preferences to Java Preferences API: migrate org.apache.cayenne.modeler.ModelerPreferences

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLJoinAppender.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLJoinAppender.java?rev=899283&r1=899282&r2=899283&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLJoinAppender.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLJoinAppender.java
Thu Jan 14 16:42:52 2010
@@ -166,7 +166,7 @@
 
                     }
 
-                    context.append(" JOIN ");
+                    context.append(" LEFT OUTER JOIN ");
                     context.append(subqueryTargetTableName).append(' ').append(
                             subqueryTargetAlias);
                     generateJoiningExpression(
@@ -330,7 +330,7 @@
                         CayenneMapEntry next = dbPathIterator.next();
                         if (next instanceof DbRelationship) {
                             DbRelationship rel = (DbRelationship) next;
-                            context.append(" JOIN ");
+                            context.append(" LEFT OUTER JOIN ");
                             String targetEntityName = rel.getTargetEntityName();
                             String subqueryTargetAlias = context.getTableAlias(id
                                     .getEntityId(), targetEntityName);

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=899283&r1=899282&r2=899283&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
Thu Jan 14 16:42:52 2010
@@ -342,7 +342,7 @@
                     }
                     else if (pathPart instanceof DbRelationship) {
                         DbRelationship rel = (DbRelationship) pathPart;
-                        dbRelationshipAdded(rel, JoinType.INNER, null);
+                        dbRelationshipAdded(rel, JoinType.LEFT_OUTER, null);
                     }
                     else if (pathPart instanceof DbAttribute) {
                         DbAttribute dbAttr = (DbAttribute) pathPart;

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=899283&r1=899282&r2=899283&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
Thu Jan 14 16:42:52 2010
@@ -118,7 +118,7 @@
         List<?> objects = context.performQuery(query);
 
         assertNotNull(objects);
-        assertEquals(3, objects.size());
+        assertEquals(8, objects.size());
         assertTrue("CompoundPainting expected, got " + objects.get(0).getClass(), objects
                 .get(0) instanceof CompoundPainting);
 
@@ -131,23 +131,32 @@
             assertEquals("CompoundPainting.getPaintingTitle(): "
                     + painting.getPaintingTitle(), "painting" + id, painting
                     .getPaintingTitle());
-            assertEquals(
-                    "CompoundPainting.getTextReview(): " + painting.getTextReview(),
-                    "painting review" + id,
-                    painting.getTextReview());
+            if (painting.getToPaintingInfo()==null){
+                assertNull(painting.getTextReview());
+            }else{
+                assertEquals("CompoundPainting.getTextReview(): "
+                        + painting.getTextReview(), "painting review" + id, painting
+                        .getTextReview());
+            }
             assertEquals(
                     "CompoundPainting.getArtistName(): " + painting.getArtistName(),
                     painting.getToArtist().getArtistName(),
                     painting.getArtistName());
-            assertEquals(
-                    "CompoundPainting.getArtistName(): " + painting.getGalleryName(),
-                    painting.getToGallery().getGalleryName(),
-                    painting.getGalleryName());
+            if (painting.getToGallery() == null) {
+                assertNull(painting.getGalleryName());
+            }
+            else {
+                assertEquals("CompoundPainting.getGalleryName(): "
+                        + painting.getGalleryName(), painting
+                        .getToGallery()
+                        .getGalleryName(), painting.getGalleryName());
+            }
         }
     }
 
     // TODO: andrus 1/5/2007 -  CAY-952: SelectQuery uses INNER JOIN for flattened attributes,
while
     // EJBQLQuery does an OUTER JOIN... which seems like a better idea...
+    // 14/01/2010 now it uses LEFT JOIN
     public void testSelectCompound2() throws Exception {
         populateTables();
         SelectQuery query = new SelectQuery(CompoundPainting.class, ExpressionFactory
@@ -155,25 +164,14 @@
         List<?> objects = context.performQuery(query);
 
         assertNotNull(objects);
-        assertEquals(1, objects.size());
+        assertEquals(2, objects.size());
         assertTrue("CompoundPainting expected, got " + objects.get(0).getClass(), objects
                 .get(0) instanceof CompoundPainting);
 
         for (Iterator<?> i = objects.iterator(); i.hasNext();) {
             CompoundPainting painting = (CompoundPainting) i.next();
             assertEquals(PersistenceState.COMMITTED, painting.getPersistenceState());
-            Number id = (Number) painting
-                    .getObjectId()
-                    .getIdSnapshot()
-                    .get("PAINTING_ID");
-            assertEquals("CompoundPainting.getObjectId(): " + id, id.intValue(), 2);
-            assertEquals("CompoundPainting.getPaintingTitle(): "
-                    + painting.getPaintingTitle(), "painting" + id, painting
-                    .getPaintingTitle());
-            assertEquals(
-                    "CompoundPainting.getTextReview(): " + painting.getTextReview(),
-                    "painting review" + id,
-                    painting.getTextReview());
+            
             assertEquals(
                     "CompoundPainting.getArtistName(): " + painting.getArtistName(),
                     "artist2",



Mime
View raw message