Package org.apache.cayenne.query
Class FluentSelect<T,S extends FluentSelect<T,S>>  
java.lang.Object
org.apache.cayenne.query.CacheableQuery
org.apache.cayenne.query.AbstractQuery
org.apache.cayenne.query.FluentSelect<T,S> 
- All Implemented Interfaces:
- Serializable,- Query,- Select<T>
- Direct Known Subclasses:
- ColumnSelect,- ObjectSelect
public abstract class FluentSelect<T,S extends FluentSelect<T,S>>  
extends AbstractQuery
implements Select<T>
Base class for 
ObjectSelect and ColumnSelect- Since:
- 4.0
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Stringprotected booleanprotected Stringprotected Class<?>protected Expressionprotected booleanprotected org.apache.cayenne.query.ObjectSelectMetadataprotected Collection<Ordering>protected ExpressionFields inherited from class org.apache.cayenne.query.AbstractQueryrootFields inherited from class org.apache.cayenne.query.CacheableQuerylogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.protected abstract org.apache.cayenne.query.ObjectSelectMetadatacreateSQLAction(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 SjoinExpression(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.protected voidroutePrefetches(QueryRouter router, EntityResolver resolver) 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 org.apache.cayenne.query.AbstractQuerygetMetaData, getRoot, setRoot, toStringMethods inherited from class org.apache.cayenne.query.CacheableQuerygetBaseMetaData, getCacheGroup, getCacheStrategy, setCacheGroup, setCacheStrategy, useLocalCache, useLocalCache, useSharedCache, useSharedCacheMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cayenne.query.QuerygetMetaDataMethods inherited from interface org.apache.cayenne.query.SelectselectFirst
- 
Field Details- 
entityType
- 
entityName
- 
dbEntityName
- 
where
- 
having
- 
havingExpressionIsActiveprotected boolean havingExpressionIsActive
- 
orderings
- 
distinctprotected boolean distinct
- 
metaDataprotected org.apache.cayenne.query.ObjectSelectMetadata metaData
 
- 
- 
Constructor Details- 
FluentSelectprotected FluentSelect()
 
- 
- 
Method Details- 
createMetadataprotected abstract org.apache.cayenne.query.ObjectSelectMetadata createMetadata()
- 
resolveRoot
- 
entityTypeSets the type of the entity to fetch without changing the return type of the query.- Returns:
- this object
 
- 
entityNameSets theObjEntityname to fetch without changing the return type of the query. This form is most often used for generic entities that don't map to a distinct class.- Returns:
- this object
 
- 
dbEntityNameSets theDbEntityname to fetch without changing the return type of the query. This form is most often used for generic entities that don't map to a distinct class.- Returns:
- this object
 
- 
whereAppends a qualifier expression of this query. An equivalent toand(Expression...)that can be used a syntactic sugar.- Returns:
- this object
 
- 
whereAppends a qualifier expression of this query, using provided expression String and an array of position parameters. This is an equivalent to calling "and".- Returns:
- this object
 
- 
andAND's provided expressions to the existing WHERE clause expression.- Returns:
- this object
 
- 
andAND's provided expressions to the existing WHERE clause expression.- Returns:
- this object
 
- 
joinExpressionprotected S joinExpression(Collection<Expression> expressions, Function<Collection<Expression>, Expression> joiner) 
- 
orOR's provided expressions to the existing WHERE clause expression.- Returns:
- this object
 
- 
orOR's provided expressions to the existing WHERE clause expression.- Returns:
- this object
 
- 
orderByAdd an ascending ordering on the given property. If there is already an ordering on this query then add this ordering with a lower priority.- Parameters:
- property- the property to sort on
- Returns:
- this object
 
- 
orderByAdd an ordering on the given property. If there is already an ordering on this query then add this ordering with a lower priority.- Parameters:
- property- the property to sort on
- sortOrder- the direction of the ordering
- Returns:
- this object
 
- 
orderByAdd one or more orderings to this query.- Returns:
- this object
 
- 
orderByAdds a list of orderings to this query.- Returns:
- this object
 
- 
prefetchMerges prefetch into the query prefetch tree.- Returns:
- this object
 
- 
prefetchMerges a prefetch path with specified semantics into the query prefetch tree.- Returns:
- this object
 
- 
limitResets query fetch limit - a parameter that defines max number of objects that should be ever be fetched from the database.
- 
offsetResets query fetch offset - a parameter that defines how many objects should be skipped when reading data from the database.
- 
pageSizeResets query page size. A non-negative page size enables query result pagination that saves memory and processing time for large lists if only parts of the result are ever going to be accessed.
- 
statementFetchSizeSets fetch size of the PreparedStatement generated for this query. Only non-negative values would change the default size.- See Also:
 
- 
queryTimeoutSets query timeout of PreparedStatement generated for this query.- See Also:
 
- 
cacheStrategy
- 
cacheStrategy
- 
cacheGroup
- 
localCacheInstructs Cayenne to look for query results in the "local" cache when running the query. This is a short-hand notation for:query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, cacheGroup); 
- 
localCacheInstructs Cayenne to look for query results in the "local" cache when running the query. This is a short-hand notation for:query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE); 
- 
getStatementFetchSizepublic int getStatementFetchSize()
- 
getQueryTimeoutpublic int getQueryTimeout()- Since:
- 4.2
 
- 
getPageSizepublic int getPageSize()
- 
getLimitpublic int getLimit()
- 
getOffsetpublic int getOffset()
- 
getEntityType
- 
getEntityName
- 
getDbEntityName
- 
getWhereReturns a WHERE clause Expression of this query.
- 
getHavingReturns a HAVING clause Expression of this query.
- 
getOrderings
- 
getPrefetches
- 
setActiveExpression
- 
getActiveExpression
- 
selectDescription copied from interface:SelectSelects objects using provided context.Essentially the inversion of "ObjectContext.select(Select)". 
- 
selectOneDescription copied from interface:SelectSelects a single object using provided context. The query is expected to match zero or one object. It returns null if no objects were matched. If query matched more than one object,CayenneRuntimeExceptionis thrown.Essentially the inversion of "ObjectContext.selectOne(Select)". 
- 
iterateDescription copied from interface:SelectCreates a ResultIterator based on the provided context and passes it to a callback for processing. The caller does not need to worry about closing the iterator. This method takes care of it.Essentially the inversion of "ObjectContext.iterate(Select, ResultIteratorCallback)". 
- 
iteratorDescription copied from interface:SelectCreates a ResultIterator based on the provided context. It is usually backed by an open result set and is useful for processing of large data sets, preserving a constant memory footprint. The caller must wrap iteration in try/finally (or try-with-resources for Java 1.7 and higher) and close the ResultIterator explicitly. Or useSelect.iterate(ObjectContext, ResultIteratorCallback)as an alternative.Essentially the inversion of "ObjectContext.iterator(Select)". 
- 
batchIteratorDescription copied from interface:SelectCreates a ResultBatchIterator based on the provided context and batch size. It is usually backed by an open result set and is useful for processing of large data sets, preserving a constant memory footprint. The caller must wrap iteration in try/finally (or try-with-resources for Java 1.7 and higher) and close the ResultBatchIterator explicitly.- Specified by:
- batchIteratorin interface- Select<T>
 
- 
createSQLActionDescription copied from interface:QueryA callback method invoked by Cayenne during the final execution phase of the query run. A concrete query implementation is given a chance to decide how it should be handled. Implementors can pick an appropriate method of the SQLActionVisitor to handle itself, create a custom SQLAction of its own, or substitute itself with another query that should be used for SQLAction construction.- Specified by:
- createSQLActionin interface- Query
- Specified by:
- createSQLActionin class- AbstractQuery
 
- 
routeDescription copied from class:AbstractQueryImplements default routing mechanism relying on the EntityResolver to find DataMap based on the query root. This mechanism should be sufficient for most queries that "know" their root.- Specified by:
- routein interface- Query
- Overrides:
- routein class- AbstractQuery
 
- 
isFetchingDataRowspublic boolean isFetchingDataRows()
- 
routePrefetches
- 
getColumns- Since:
- 4.2
 
- 
isDistinctpublic boolean isDistinct()- Since:
- 4.2
 
- 
initWithProperties- Since:
- 4.2
 
- 
castSelfprotected <E> E castSelf()Utility method to perform (re)cast this type, doesn't perform any checks, so use with caution.- Type Parameters:
- E- type to cast to
- Returns:
- thiscasted to the type E
- Since:
- 5.0
 
 
-