cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [3/5] cayenne git commit: CAY-2406 Add prefetch-related API to SQLSelect
Date Wed, 14 Feb 2018 13:33:42 GMT
CAY-2406 Add prefetch-related API to SQLSelect


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/9183314a
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/9183314a
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/9183314a

Branch: refs/heads/master
Commit: 9183314a9e1d361e14c13cd5f208a71533b5fe8e
Parents: 90e5273
Author: Maxim Petrusevich <maks1464@gmail.com>
Authored: Wed Feb 14 10:30:37 2018 +0300
Committer: Maxim Petrusevich <maks1464@gmail.com>
Committed: Wed Feb 14 10:30:37 2018 +0300

----------------------------------------------------------------------
 .../java/org/apache/cayenne/query/SQLTemplate.java | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/9183314a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java b/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
index 5a84322..c86bb00 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.query;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.QueryEngine;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
@@ -34,7 +35,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeSet;
 import java.util.function.Function;
 import java.util.stream.Stream;
 
@@ -502,9 +502,24 @@ public class SQLTemplate extends AbstractQuery implements ParameterizedQuery
{
 	 * @since 4.0
 	 */
 	public void addPrefetch(PrefetchTreeNode prefetchElement) {
+		if (hasDisjointNode(prefetchElement)) {
+			throw new CayenneRuntimeException("This query supports only 'joint' and 'disjointById'
prefetching semantics.");
+		}
 		metaData.mergePrefetch(prefetchElement);
 	}
 
+	private boolean hasDisjointNode(PrefetchTreeNode prefetchElement) {
+		if (prefetchElement.isDisjointPrefetch()) {
+			return true;
+		}
+		for (PrefetchTreeNode child : prefetchElement.getChildren()) {
+			if (hasDisjointNode(child)) {
+				return true;
+			}
+		}
+		return false;
+	}
+
 	/**
 	 * @since 1.2
 	 */


Mime
View raw message