1 19 20 package org.apache.cayenne.query; 21 22 import java.util.Collection ; 23 import java.util.Collections ; 24 import java.util.HashSet ; 25 26 import org.apache.cayenne.map.EntityResolver; 27 import org.apache.cayenne.map.ObjRelationship; 28 import org.apache.cayenne.util.Util; 29 30 36 public class PrefetchSelectQuery extends SelectQuery { 37 38 protected SelectQuery parentQuery; 39 40 43 protected String prefetchPath; 44 45 48 protected ObjRelationship lastPrefetchHint; 49 50 protected Collection resultPaths; 53 54 59 public PrefetchSelectQuery(SelectQuery parentQuery, String prefetchPath, 60 ObjRelationship lastPrefetchHint) { 61 62 setRoot(lastPrefetchHint.getTargetEntity()); 63 this.parentQuery = parentQuery; 64 this.prefetchPath = prefetchPath; 65 this.lastPrefetchHint = lastPrefetchHint; 66 } 67 68 74 void routePrefetches(QueryRouter router, EntityResolver resolver) { 75 } 77 78 83 public String getPrefetchPath() { 84 return prefetchPath; 85 } 86 87 92 public void setPrefetchPath(String prefetchPath) { 93 this.prefetchPath = prefetchPath; 94 } 95 96 99 public SelectQuery getParentQuery() { 100 return parentQuery; 101 } 102 103 106 public void setParentQuery(SelectQuery parentQuery) { 107 this.parentQuery = parentQuery; 108 } 109 110 115 public ObjRelationship getLastPrefetchHint() { 116 return lastPrefetchHint; 117 } 118 119 122 public void setLastPrefetchHint(ObjRelationship relationship) { 123 lastPrefetchHint = relationship; 124 } 125 126 133 public void addResultPath(String path) { 134 if (Util.isEmptyString(path)) { 135 throw new IllegalArgumentException ("Invalid path: " + path); 136 } 137 138 nonNullResultPaths().add(path); 139 } 140 141 147 public void removeResultPath(String path) { 148 if (resultPaths != null) { 149 resultPaths.remove(path); 150 } 151 } 152 153 158 public Collection getResultPaths() { 159 return resultPaths != null 160 ? Collections.unmodifiableCollection(resultPaths) 161 : Collections.EMPTY_SET; 162 } 163 164 170 Collection nonNullResultPaths() { 171 if (resultPaths == null) { 172 resultPaths = new HashSet (); 173 } 174 175 return resultPaths; 176 } 177 } 178 | Popular Tags |