Class PrefetchSelectQuery<T>
java.lang.Object
org.apache.cayenne.query.CacheableQuery
org.apache.cayenne.query.AbstractQuery
org.apache.cayenne.query.FluentSelect<T, ObjectSelect<T>>
org.apache.cayenne.query.ObjectSelect<T>
org.apache.cayenne.query.PrefetchSelectQuery<T>
- All Implemented Interfaces:
Serializable, ParameterizedQuery, Query, Select<T>
A SelectQuery to perform a prefetch based on another query. Used internally by Cayenne
and is normally never used directly.
- Since:
- 4.2 this query extends
ObjectSelect - See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ObjRelationshipStores the last ObjRelationship in the prefetch path.protected CayennePathThe relationship path from root objects to the objects being prefetched.protected Collection<ASTPath> Fields inherited from class FluentSelect
dbEntityName, distinct, entityName, entityType, having, havingExpressionIsActive, metaData, orderings, whereModifier and TypeFieldDescriptionprotected Stringprotected booleanprotected Stringprotected Class<?> protected Expressionprotected booleanprotected org.apache.cayenne.query.ObjectSelectMetadataprotected Collection<Ordering> protected ExpressionFields inherited from class AbstractQuery
rootFields inherited from class CacheableQuery
logger -
Constructor Summary
ConstructorsConstructorDescriptionPrefetchSelectQuery(CayennePath prefetchPath, ObjRelationship lastPrefetchHint) Creates a new disjoint prefetch select query. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResultPath(String path) Configures an "extra" path that will resolve to an extra column (or columns) in the result set.voidaddResultPath(Expression path) Configures an "extra" path that will resolve to an extra column (or columns) in the result set.Returns last incoming ObjRelationship in the prefetch relationship chain.Returns the prefetchPath.Returns extra result paths.voidremoveResultPath(String path) Removes an extra result path.voidremoveResultPath(CayennePath path) Removes an extra result path.protected voidroutePrefetches(QueryRouter router, EntityResolver resolver) voidsetLastPrefetchHint(ObjRelationship relationship) voidsetPrefetchPath(String prefetchPath) Sets the prefetchPath.voidsetPrefetchPath(CayennePath prefetchPath) Sets the prefetchPath.voidsetPrefetchTree(PrefetchTreeNode prefetch) Clean set of the prefetch tree without any merge with existing nodes.Methods inherited from class ObjectSelect
aggregate, avg, column, columnQuery, columnQuery, columns, count, count, createMetadata, createQuery, dataRowQuery, dataRowQuery, dbQuery, dbQuery, distinct, fetchDataRows, getBaseMetaData, getMetaData, having, having, max, max, min, min, query, query, query, query, selectCount, selectFirst, sumModifier and TypeMethodDescription<E> ColumnSelect<E> aggregate(BaseProperty<E> property, String function, Class<E> type) Select result of some function, that aggregates values.<E extends Number>
ColumnSelect<E> avg(NumericProperty<E> property) Select average value of property<E> ColumnSelect<E> Select one specific property.static ColumnSelect<Object[]> columnQuery(Class<?> entityType, Property<?>... columns) Creates a ColumnSelect that will fetch multiple columns of a givenObjEntitystatic <E> ColumnSelect<E> columnQuery(Class<?> entityType, Property<E> column) Creates a ColumnSelect that will fetch single property that can be resolved against a givenObjEntityclass.Select only specific properties.count()Select COUNT(*)count(BaseProperty<?> property) Select COUNT(property)protected org.apache.cayenne.query.ObjectSelectMetadatacreateQuery(Map<String, ?> parameters) This method is intended for internal use in aMappedSelect.static ObjectSelect<DataRow> dataRowQuery(Class<?> entityType) Creates a ObjectSelect that fetches data for anObjEntitydetermined from a provided class.static ObjectSelect<DataRow> dataRowQuery(Class<?> entityType, Expression expression) Creates a ObjectSelect that fetches data for anObjEntitydetermined from a provided class and uses provided expression for its qualifier.static ObjectSelect<DataRow> Creates a ObjectSelect that fetches DataRows for aDbEntitydetermined from provided "dbEntityName".static ObjectSelect<DataRow> dbQuery(String dbEntityName, Expression expression) Creates a ObjectSelect that fetches DataRows for aDbEntitydetermined from provided "dbEntityName" and uses provided expression for its qualifier.distinct()Forces query to fetch DataRows.protected org.apache.cayenne.query.ObjectSelectMetadatagetMetaData(EntityResolver resolver) Returns default select parameters.Appends a having qualifier expression of this query, using provided expression String and an array of position parameters.having(Expression expression) Appends a having qualifier expression of this query.<E> ColumnSelect<E> max(ComparableProperty<E> property) Select maximum value of property<E extends Number>
ColumnSelect<E> max(NumericProperty<E> property) Select maximum value of property<E> ColumnSelect<E> min(ComparableProperty<E> property) Select minimum value of property<E extends Number>
ColumnSelect<E> min(NumericProperty<E> property) Select minimum value of propertystatic <T> ObjectSelect<T> Creates a ObjectSelect that selects objects of a given persistent class.static <T> ObjectSelect<T> Creates a ObjectSelect that fetches data forObjEntitydetermined from provided "entityName", but fetches the result of a provided type.static <T> ObjectSelect<T> query(Class<T> entityType, Expression expression) Creates a ObjectSelect that selects objects of a given persistent class and uses provided expression for its qualifier.static <T> ObjectSelect<T> query(Class<T> entityType, Expression expression, List<Ordering> orderings) Creates a ObjectSelect that selects objects of a given persistent class and uses provided expression for its qualifier.longselectCount(ObjectContext context) Quick way to select count of recordsselectFirst(ObjectContext context) Selects a single object using provided context.<E extends Number>
ColumnSelect<E> sum(NumericProperty<E> property) Select sum of valuesMethods inherited from class FluentSelect
and, and, batchIterator, cacheGroup, cacheStrategy, cacheStrategy, castSelf, createSQLAction, dbEntityName, entityName, entityType, getActiveExpression, getColumns, getDbEntityName, getEntityName, getEntityType, getHaving, getLimit, getOffset, getOrderings, getPageSize, getPrefetches, getQueryTimeout, getStatementFetchSize, getWhere, initWithProperties, isDistinct, isFetchingDataRows, iterate, iterator, joinExpression, limit, localCache, localCache, offset, or, or, orderBy, orderBy, orderBy, orderBy, pageSize, prefetch, prefetch, queryTimeout, resolveRoot, route, select, selectOne, setActiveExpression, sharedCache, sharedCache, statementFetchSize, where, whereModifier and TypeMethodDescriptionand(Collection<Expression> expressions) AND's provided expressions to the existing WHERE clause expression.and(Expression... expressions) AND's provided expressions to the existing WHERE clause expression.batchIterator(ObjectContext context, int size) Creates a ResultBatchIterator based on the provided context and batch size.cacheGroup(String cacheGroup) cacheStrategy(QueryCacheStrategy strategy) cacheStrategy(QueryCacheStrategy strategy, String cacheGroup) protected <E> EcastSelf()Utility method to perform (re)cast this type, doesn't perform any checks, so use with caution.createSQLAction(SQLActionVisitor visitor) A callback method invoked by Cayenne during the final execution phase of the query run.dbEntityName(String dbEntityName) Sets theDbEntityname to fetch without changing the return type of the query.entityName(String entityName) Sets theObjEntityname to fetch without changing the return type of the query.entityType(Class<?> entityType) Sets the type of the entity to fetch without changing the return type of the query.protected ExpressionCollection<Property<?>> Class<?> Returns a HAVING clause Expression of this query.intgetLimit()intintintintgetWhere()Returns a WHERE clause Expression of this query.voidinitWithProperties(Map<String, String> properties) booleanbooleanvoiditerate(ObjectContext context, ResultIteratorCallback<T> callback) Creates a ResultIterator based on the provided context and passes it to a callback for processing.iterator(ObjectContext context) Creates a ResultIterator based on the provided context.protected ObjectSelect<T> joinExpression(Collection<Expression> expressions, Function<Collection<Expression>, Expression> joiner) limit(int fetchLimit) Resets query fetch limit - a parameter that defines max number of objects that should be ever be fetched from the database.Instructs Cayenne to look for query results in the "local" cache when running the query.localCache(String cacheGroup) Instructs Cayenne to look for query results in the "local" cache when running the query.offset(int fetchOffset) Resets query fetch offset - a parameter that defines how many objects should be skipped when reading data from the database.or(Collection<Expression> expressions) OR's provided expressions to the existing WHERE clause expression.or(Expression... expressions) OR's provided expressions to the existing WHERE clause expression.Add an ascending ordering on the given property.Add an ordering on the given property.orderBy(Collection<Ordering> orderings) Adds a list of orderings to this query.Add one or more orderings to this query.pageSize(int pageSize) Resets query page size.Merges a prefetch path with specified semantics into the query prefetch tree.prefetch(PrefetchTreeNode prefetch) Merges prefetch into the query prefetch tree.queryTimeout(int timeout) Sets query timeout of PreparedStatement generated for this query.protected ObjectresolveRoot(EntityResolver resolver) voidroute(QueryRouter router, EntityResolver resolver, Query substitutedQuery) Implements default routing mechanism relying on the EntityResolver to find DataMap based on the query root.select(ObjectContext context) Selects objects using provided context.selectOne(ObjectContext context) Selects a single object using provided context.protected voidInstructs Cayenne to look for query results in the "shared" cache when running the query.sharedCache(String cacheGroup) Instructs Cayenne to look for query results in the "shared" cache when running the query.statementFetchSize(int size) Sets fetch size of the PreparedStatement generated for this query.Appends a qualifier expression of this query, using provided expression String and an array of position parameters.where(Expression expression) Appends a qualifier expression of this query.Methods inherited from class AbstractQuery
getRoot, setRoot, toStringMethods inherited from class CacheableQuery
getCacheGroup, getCacheStrategy, setCacheGroup, setCacheStrategy, useLocalCache, useLocalCache, useSharedCache, useSharedCacheModifier and TypeMethodDescriptionvoidsetCacheGroup(String cacheGroup) voidsetCacheStrategy(QueryCacheStrategy strategy) voidInstructs Cayenne to look for query results in the "local" cache when running the query.voiduseLocalCache(String cacheGroup) Instructs Cayenne to look for query results in the "local" cache when running the query.voidInstructs Cayenne to look for query results in the "shared" cache when running the query.voiduseSharedCache(String cacheGroup) Instructs Cayenne to look for query results in the "shared" cache when running the query.
-
Field Details
-
prefetchPath
The relationship path from root objects to the objects being prefetched. -
lastPrefetchHint
Stores the last ObjRelationship in the prefetch path. -
resultPaths
-
-
Constructor Details
-
PrefetchSelectQuery
Creates a new disjoint prefetch select query.- Since:
- 3.1
-
-
Method Details
-
routePrefetches
- Overrides:
routePrefetchesin classFluentSelect<T, ObjectSelect<T>>
-
getPrefetchPath
Returns the prefetchPath.- Since:
- 5.0 returns
CayennePathinstead of a plainString
-
setPrefetchPath
Sets the prefetchPath.- Parameters:
prefetchPath- The prefetchPath to set- See Also:
-
setPrefetchPath
Sets the prefetchPath.- Parameters:
prefetchPath- The prefetchPath to set- Since:
- 5.0
-
setPrefetchTree
Clean set of the prefetch tree without any merge with existing nodes.- Parameters:
prefetch- prefetch tree- Since:
- 4.2
-
getLastPrefetchHint
Returns last incoming ObjRelationship in the prefetch relationship chain.- Since:
- 1.1
-
setLastPrefetchHint
- Since:
- 1.1
-
addResultPath
Configures an "extra" path that will resolve to an extra column (or columns) in the result set.- Parameters:
path- A valid path expression. E.g. "abc" or "db:ABC" or "abc.xyz".- Since:
- 1.2
-
addResultPath
Configures an "extra" path that will resolve to an extra column (or columns) in the result set.- Parameters:
path- a path expression- Since:
- 5.0
-
removeResultPath
Removes an extra result path. Note that this method doesn't check for expression invariants, as it doesn't have a proper context to do so. E.g. for the purpose of this method "db:ARTIST_NAME" and "obj:artistName" are not the same, though both will resolve to the same column name.- See Also:
-
removeResultPath
Removes an extra result path. Note that this method doesn't check for expression invariants, as it doesn't have a proper context to do so. E.g. for the purpose of this method "db:ARTIST_NAME" and "obj:artistName" are not the same, though both will resolve to the same column name.- Since:
- 5.0
-
getResultPaths
Returns extra result paths.- Since:
- 1.2, 5.0 returns collection of
CayennePath
-