Class FluentSelect<T, S extends FluentSelect<T,S> >
java.lang.Object
org.apache.cayenne.query.FluentSelect<T,S>
- Direct Known Subclasses:
ColumnSelect, ObjectSelect
public abstract class FluentSelect<T, S extends FluentSelect<T,S>>
extends Object
implements Select<T>
Base class for
ObjectSelect and ColumnSelect- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected booleanprotected Stringprotected Class<?> protected Expressionprotected booleanprotected org.apache.cayenne.query.ObjectSelectMetadataprotected Collection<Ordering> protected Expression -
Constructor Summary
Constructors -
Method Summary
Modifier 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.Appends a qualifier matching a single object of the root entity by its id.Appends a qualifier matching any of the objects of the root entity with the given ids.byIds(Collection<?> ids) Appends a qualifier matching any of the objects of the root entity with the given ids.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 Expressionprotected abstract org.apache.cayenne.query.ObjectSelectMetadataCollection<Property<?>> Class<?> Returns a HAVING clause Expression of this query.intgetLimit()intintintintgetWhere()Returns a WHERE clause Expression of this query.booleanbooleanprotected 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) A callback method invoked by Cayenne during the routing phase of the query execution.protected voidroutePrefetches(QueryRouter router, EntityResolver resolver) protected voidvoidsetCacheGroup(String cacheGroup) Deprecated, for removal: This API element is subject to removal in a future version.voidsetCacheStrategy(QueryCacheStrategy strategy) Deprecated, for removal: This API element is subject to removal in a future version.Instructs 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.voidDeprecated, for removal: This API element is subject to removal in a future version.uselocalCache()voiduseLocalCache(String cacheGroup) Deprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.usesharedCache()voiduseSharedCache(String cacheGroup) Deprecated, for removal: This API element is subject to removal in a future version.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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Query
getMetaDataMethods inherited from interface Select
batchIterator, iterate, iterator, select, selectFirst, selectOne
-
Field Details
-
entityType
-
entityName
-
dbEntityName
-
where
-
having
-
havingExpressionIsActive
protected boolean havingExpressionIsActive -
orderings
-
distinct
protected boolean distinct -
metaData
protected org.apache.cayenne.query.ObjectSelectMetadata metaData
-
-
Constructor Details
-
FluentSelect
protected FluentSelect()
-
-
Method Details
-
createMetadata
protected abstract org.apache.cayenne.query.ObjectSelectMetadata createMetadata() -
getBaseMetaData
protected abstract org.apache.cayenne.query.ObjectSelectMetadata getBaseMetaData() -
resolveRoot
-
entityType
-
entityName
-
dbEntityName
-
where
Appends a qualifier expression of this query. An equivalent toand(Expression...)that can be used a syntactic sugar.- Returns:
- this object
-
where
-
byId
Appends a qualifier matching a single object of the root entity by its id. The id can be one of:- a scalar, for entities with a single-column PK, e.g.
byId(1); - a
Mapof PK column names to values, e.g.byId(Map.of("KEY1", "x", "KEY2", "y")), which is the form to use for a compound PK; - an
ObjectIdof the root entity, matched by its id snapshot.
where(Expression)with one of the "id" expressions of the root entity "self" property, so it combines with any other query settings. Likewhere(..), it is AND'ed to any qualifier set previously.- Parameters:
id- a scalar, aMapor anObjectId- Since:
- 5.0
- a scalar, for entities with a single-column PK, e.g.
-
byIds
Appends a qualifier matching any of the objects of the root entity with the given ids. Each id can be a scalar, aMapof PK column names to values or anObjectId, and the forms can be mixed. Scalars are combined into a singleIN, the rest into anORof per-id matches. An empty array matches nothing.- Parameters:
ids- scalars,Maps orObjectIds- Returns:
- this object
- Since:
- 5.0
-
byIds
Appends a qualifier matching any of the objects of the root entity with the given ids. Each id can be a scalar, aMapof PK column names to values or anObjectId, and the forms can be mixed. Scalars are combined into a singleIN, the rest into anORof per-id matches. An empty collection matches nothing.- Parameters:
ids- scalars,Maps orObjectIds- Returns:
- this object
- Since:
- 5.0
-
and
AND's provided expressions to the existing WHERE clause expression.- Returns:
- this object
-
and
AND's provided expressions to the existing WHERE clause expression.- Returns:
- this object
-
joinExpression
protected S joinExpression(Collection<Expression> expressions, Function<Collection<Expression>, Expression> joiner) -
or
OR's provided expressions to the existing WHERE clause expression.- Returns:
- this object
-
or
OR's provided expressions to the existing WHERE clause expression.- Returns:
- this object
-
orderBy
-
orderBy
-
orderBy
-
orderBy
Adds a list of orderings to this query.- Returns:
- this object
-
prefetch
Merges prefetch into the query prefetch tree.- Returns:
- this object
-
prefetch
-
limit
Resets query fetch limit - a parameter that defines max number of objects that should be ever be fetched from the database. -
offset
Resets query fetch offset - a parameter that defines how many objects should be skipped when reading data from the database. -
pageSize
Resets 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. -
statementFetchSize
Sets fetch size of the PreparedStatement generated for this query. Any non-zero value is passed to the driver as is; 0 (the default) leaves the fetch size to the adapter and the driver. A negative value is only meaningful for drivers that give it a special meaning, such asInteger.MIN_VALUEfor streaming on MySQL.- See Also:
-
queryTimeout
Sets query timeout of PreparedStatement generated for this query.- See Also:
-
cacheStrategy
-
cacheStrategy
-
cacheGroup
-
localCache
-
localCache
Instructs 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);
-
getCacheStrategy
- Since:
- 3.0
-
getCacheGroup
- Since:
- 4.0
-
setCacheStrategy
Deprecated, for removal: This API element is subject to removal in a future version.Note that unlikecacheStrategy(QueryCacheStrategy)this method preserves the existing cache group. To reset it, usecacheStrategy(QueryCacheStrategy, String).- Since:
- 3.0
-
setCacheGroup
Deprecated, for removal: This API element is subject to removal in a future version.- Since:
- 4.0
-
useLocalCache
Deprecated, for removal: This API element is subject to removal in a future version.uselocalCache()- Since:
- 4.0
-
useLocalCache
Deprecated, for removal: This API element is subject to removal in a future version.- Since:
- 4.0
-
getStatementFetchSize
public int getStatementFetchSize() -
getQueryTimeout
public int getQueryTimeout()- Since:
- 4.2
-
getPageSize
public int getPageSize() -
getLimit
public int getLimit() -
getOffset
public int getOffset() -
getEntityType
-
getEntityName
-
getDbEntityName
-
getWhere
Returns a WHERE clause Expression of this query. -
getHaving
Returns a HAVING clause Expression of this query. -
getOrderings
-
getPrefetches
-
setActiveExpression
-
getActiveExpression
-
createSQLAction
Description 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 interfaceQuery
-
route
Description copied from interface:QueryA callback method invoked by Cayenne during the routing phase of the query execution. Mapping of DataNodes is provided by QueryRouter. Query should use aQueryRouter.route(DataNode, Query, Query)callback method to route itself. Query can create one or more substitute queries or even provide its own DataNode to execute itself.The default implementation relies on the EntityResolver to find the DataMap based on the query metadata. This mechanism is sufficient for most queries that "know" their root.
-
isFetchingDataRows
public boolean isFetchingDataRows() -
routePrefetches
-
getColumns
- Since:
- 4.2
-
isDistinct
public boolean isDistinct()- Since:
- 4.2
-
castSelf
protected <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
-
cacheGroup(String)