cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1576306 - in /cayenne/main/branches/STABLE-3.1: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/
Date Tue, 11 Mar 2014 12:21:11 GMT
Author: aadamchik
Date: Tue Mar 11 12:21:11 2014
New Revision: 1576306

URL: http://svn.apache.org/r1576306
Log:
CAY-1905 Multi-step prefetching NPE : 1..N..1 with absent N and root with no qualifier

Modified:
    cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepTest.java

Modified: cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1576306&r1=1576305&r2=1576306&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/branches/STABLE-3.1/docs/doc/src/main/resources/RELEASE-NOTES.txt Tue Mar
11 12:21:11 2014
@@ -12,8 +12,11 @@ Release: 3.1-final
 Date: not yet released
 ----------------------------------
 Changes/New Features Since 3.1RC1:
+
 Bug Fixes Since 3.1RC1:
 
+CAY-1905 Multi-step prefetching NPE : 1..N..1 with absent N and root with no qualifier
+
 ----------------------------------
 Release: 3.1RC1
 Date: 16 February 2014

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java?rev=1576306&r1=1576305&r2=1576306&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ResultScanParentAttachmentStrategy.java
Tue Mar 11 12:21:11 2014
@@ -100,6 +100,12 @@ class ResultScanParentAttachmentStrategy
         partitionByChild = new HashMap<Object, List<Persistent>>();
 
         List<Persistent> objects = parentNode.getObjects();
+        
+        // null is possible if the parent node matched no objects...
+        if(objects == null) {
+            return;
+        }
+        
         List<DataRow> rows = parentNode.getDataRows();
         int size = objects.size();
         for (int i = 0; i < size; i++) {

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepTest.java?rev=1576306&r1=1576305&r2=1576306&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepTest.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextPrefetchMultistepTest.java
Tue Mar 11 12:21:11 2014
@@ -39,6 +39,7 @@ import org.apache.cayenne.test.jdbc.Tabl
 import org.apache.cayenne.testdo.testmap.ArtistExhibit;
 import org.apache.cayenne.testdo.testmap.Exhibit;
 import org.apache.cayenne.testdo.testmap.Gallery;
+import org.apache.cayenne.testdo.testmap.Painting;
 import org.apache.cayenne.unit.di.server.ServerCase;
 import org.apache.cayenne.unit.di.server.UseServerRuntime;
 
@@ -78,7 +79,7 @@ public class DataContextPrefetchMultiste
         tGallery = new TableHelper(dbHelper, "GALLERY");
         tGallery.setColumns("GALLERY_ID", "GALLERY_NAME");
     }
-
+    
     protected void createTwoArtistsWithExhibitsDataSet() throws Exception {
         tArtist.insert(11, "artist2");
         tArtist.insert(101, "artist3");
@@ -100,6 +101,15 @@ public class DataContextPrefetchMultiste
         tArtistExhibit.insert(101, 2);
         tArtistExhibit.insert(101, 4);
     }
+    
+    protected void createGalleriesAndArtists() throws Exception {
+        tArtist.insert(11, "artist2");
+        tArtist.insert(101, "artist3");
+
+        tGallery.insert(25, "gallery1");
+        tGallery.insert(31, "gallery2");
+        tGallery.insert(45, "gallery3");
+    }
 
     public void testToManyToManyFirstStepUnresolved() throws Exception {
 
@@ -258,4 +268,24 @@ public class DataContextPrefetchMultiste
         ArtistExhibit ae1 = aexhibits.get(0);
         assertEquals(PersistenceState.COMMITTED, ae1.getPersistenceState());
     }
+    
+    public void testToManyToOne_EmptyToMany_NoRootQualifier() throws Exception {
+
+        createGalleriesAndArtists();
+
+        SelectQuery q = new SelectQuery(Gallery.class);
+        q.addPrefetch(Gallery.PAINTING_ARRAY_PROPERTY);
+        q.addPrefetch(Gallery.PAINTING_ARRAY_PROPERTY + "." + Painting.TO_ARTIST_PROPERTY);
+
+        List<Gallery> galleries = context.performQuery(q);
+        assertEquals(3, galleries.size());
+
+        Gallery g = galleries.get(0);
+
+        // this relationship should be resolved
+        assertTrue(g.readPropertyDirectly(Gallery.PAINTING_ARRAY_PROPERTY) instanceof ValueHolder);
+        List<Painting> exhibits = (List<Painting>) g.readPropertyDirectly(Gallery.PAINTING_ARRAY_PROPERTY);
+        assertFalse(((ValueHolder) exhibits).isFault());
+        assertEquals(0, exhibits.size());
+    }
 }



Mime
View raw message