You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2019/12/23 14:00:43 UTC

[cayenne] branch master updated: CAY-2643 ObjectSelect.prefetch(name, semantics) method creates a phantom node

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 89ecb41  CAY-2643 ObjectSelect.prefetch(name, semantics) method creates a phantom node
89ecb41 is described below

commit 89ecb41e0d23620be10dced778d6844ae5069a9c
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Tue Dec 17 18:23:12 2019 +0300

    CAY-2643 ObjectSelect.prefetch(name, semantics) method creates a phantom node
---
 .../cayenne/access/DataContextPrefetchIT.java      | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextPrefetchIT.java b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextPrefetchIT.java
index 1b462f2..5f6c522 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextPrefetchIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DataContextPrefetchIT.java
@@ -240,6 +240,31 @@ public class DataContextPrefetchIT extends ServerCase {
 		});
 	}
 
+	@Test
+	public void testPrefetchByPathToManyNoQualifier() throws Exception {
+		createTwoArtistsAndTwoPaintingsDataSet();
+
+		List<Artist> artists = ObjectSelect.query(Artist.class)
+				.prefetch("paintingArray", PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS)
+				.select(context);
+
+		queryInterceptor.runWithQueriesBlocked(() -> {
+
+			assertEquals(2, artists.size());
+
+			for (int i = 0; i < 2; i++) {
+				Artist a = artists.get(i);
+				List<?> toMany = (List<?>) a.readPropertyDirectly("paintingArray");
+				assertNotNull(toMany);
+				assertFalse(((ValueHolder) toMany).isFault());
+				assertEquals(1, toMany.size());
+
+				Painting p = (Painting) toMany.get(0);
+				assertEquals("Invalid prefetched painting:" + p, "p_" + a.getArtistName(), p.getPaintingTitle());
+			}
+		});
+	}
+
 	/**
 	 * Test that a to-many relationship is initialized when a target entity has
 	 * a compound PK only partially involved in relationship.