Class SelectQuery<T>
- All Implemented Interfaces:
Serializable
,ParameterizedQuery
,Query
,Select<T>
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Deprecated.Flag that indicates whether this query can return single value or it should always return some complex data (Object[] for now)protected Collection
<Property<?>> Deprecated.protected boolean
Deprecated.static final boolean
Deprecated.static final String
Deprecated.protected Expression
Deprecated.Deprecated.protected Expression
Deprecated.Fields inherited from class org.apache.cayenne.query.AbstractQuery
root
Fields inherited from class org.apache.cayenne.query.CacheableQuery
logger
-
Constructor Summary
ConstructorDescriptionDeprecated.Creates an empty SelectQuery.SelectQuery
(Class<T> rootClass) Deprecated.Creates a SelectQuery that selects all objects of a given persistent class.SelectQuery
(Class<T> rootClass, Expression qualifier) Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.SelectQuery
(Class<T> rootClass, Expression qualifier, List<? extends Ordering> orderings) Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.SelectQuery
(String objEntityName) Deprecated.Creates SelectQuery withobjEntityName
parameter.SelectQuery
(String objEntityName, Expression qualifier) Deprecated.Creates SelectQuery withobjEntityName
andqualifier
parameters.SelectQuery
(String objEntityName, Expression qualifier, List<? extends Ordering> orderings) Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.SelectQuery
(DbEntity root) Deprecated.Creates a SelectQuery for the specified DbEntity.SelectQuery
(DbEntity root, Expression qualifier) Deprecated.Creates a SelectQuery for the specified DbEntity with the given qualifier.SelectQuery
(DbEntity root, Expression qualifier, List<? extends Ordering> orderings) Deprecated.Creates a SelectQuery for the specified DbEntity with the given qualifier and orderings.SelectQuery
(ObjEntity root) Deprecated.Creates a SelectQuery with null qualifier, for the specifed ObjEntitySelectQuery
(ObjEntity root, Expression qualifier) Deprecated.Creates a SelectQuery for the specified ObjEntity with the given qualifier.SelectQuery
(ObjEntity root, Expression qualifier, List<? extends Ordering> orderings) Deprecated.Creates a SelectQuery for the specified ObjEntity with the given qualifier and orderings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOrdering
(String sortPathSpec, SortOrder order) Deprecated.Adds ordering specification to this query orderings.void
addOrdering
(Ordering ordering) Deprecated.Adds ordering specification to this query orderings.void
addOrderings
(Collection<? extends Ordering> orderings) Deprecated.Adds a list of orderings.addPrefetch
(String prefetchPath) Deprecated.Adds a prefetch with specified relationship path to the query.void
addPrefetch
(PrefetchTreeNode prefetchElement) Deprecated.Adds a prefetch with specified relationship path to the query.void
aliasPathSplits
(String path, String... aliases) Deprecated.Adds one or more aliases for the qualifier expression path.void
Deprecated.Adds specified HAVING qualifier to the existing HAVING qualifier joining it using "AND".void
Deprecated.Adds specified qualifier to the existing qualifier joining it using "AND".batchIterator
(ObjectContext context, int size) Deprecated.Creates a ResultBatchIterator based on the provided context and batch size.boolean
Deprecated.void
Deprecated.Clears all configured orderings.void
Deprecated.Clears all stored prefetch paths.createQuery
(Map<String, ?> parameters) Deprecated.Creates and returns a new SelectQuery built using this query as a prototype and substituting qualifier parameters with the values from the map.createSQLAction
(SQLActionVisitor visitor) Deprecated.Calls "makeSelect" on the visitor.static SelectQuery
<DataRow> dataRowQuery
(Class<?> rootClass) Deprecated.static SelectQuery
<DataRow> dataRowQuery
(Class<?> rootClass, Expression qualifier) Deprecated.Creates a SelectQuery that selects DataRows that correspond to a given persistent class that match supplied qualifier.static SelectQuery
<DataRow> dataRowQuery
(Class<?> rootClass, Expression qualifier, List<Ordering> orderings) Deprecated.protected org.apache.cayenne.query.BaseQueryMetadata
Deprecated.Collection
<Property<?>> Deprecated.int
Deprecated.Returns the fetchLimit.int
Deprecated.Returns the fetchOffset.Deprecated.Returns query HAVING qualifier.getMetaData
(EntityResolver resolver) Deprecated.Returns default select parameters.Deprecated.Returns a list of orderings used by this query.int
Deprecated.ReturnspageSize
property.Deprecated.Deprecated.Returns query qualifier.int
Deprecated.void
initWithProperties
(Map<String, ?> properties) Deprecated.Initializes query parameters using a set of properties.boolean
Deprecated.Returns true if this query returns distinct rows.boolean
Deprecated.Returnstrue
if this query should produce a list of data rows as opposed to DataObjects,false
for DataObjects.void
iterate
(ObjectContext context, ResultIteratorCallback<T> callback) Deprecated.Creates a ResultIterator based on the provided context and passes it to a callback for processing.iterator
(ObjectContext context) Deprecated.Creates a ResultIterator based on the provided context.void
Deprecated.Adds specified HAVING qualifier to the existing HAVING qualifier joining it using "OR".void
Deprecated.Adds specified qualifier to the existing qualifier joining it using "OR".static <T> SelectQuery
<T> Deprecated.Creates a SelectQuery that selects objects of a given persistent class.static <T> SelectQuery
<T> query
(Class<T> rootClass, Expression qualifier) Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.static <T> SelectQuery
<T> query
(Class<T> rootClass, Expression qualifier, List<? extends Ordering> orderings) Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.queryWithParameters
(Map<String, ?> parameters) Deprecated.A shortcut forqueryWithParameters(Map, boolean)
that prunes parts of qualifier that have no parameter value set.queryWithParameters
(Map<String, ?> parameters, boolean pruneMissing) Deprecated.Returns a query built using this query as a prototype, using a set of parameters to build the qualifier.void
removeOrdering
(Ordering ordering) Deprecated.Removes ordering.void
removePrefetch
(String prefetchPath) Deprecated.Removes prefetch.void
route
(QueryRouter router, EntityResolver resolver, Query substitutedQuery) Deprecated.Routes itself and if there are any prefetches configured, creates prefetch queries and routes them as well.select
(ObjectContext context) Deprecated.Selects objects using provided context.selectFirst
(ObjectContext context) Deprecated.Selects a single object using provided context.selectOne
(ObjectContext context) Deprecated.Selects a single object using provided context.void
setCanReturnScalarValue
(boolean canReturnScalarValue) Deprecated.Flag that indicates whether this query can return single value or it should always return some complex data (Object[] for now)void
setColumns
(Collection<Property<?>> columns) Deprecated.void
setColumns
(Property<?>... columns) Deprecated.void
setDistinct
(boolean distinct) Deprecated.Setsdistinct
property that determines whether this query returns distinct row.void
setFetchingDataRows
(boolean flag) Deprecated.since 4.0, usedataRowQuery(Class, Expression)
to create DataRow query instead.void
setFetchLimit
(int fetchLimit) Deprecated.Sets the fetchLimit.void
setFetchOffset
(int fetchOffset) Deprecated.void
setHavingQualifier
(Expression qualifier) Deprecated.Sets new query HAVING qualifier.void
setPageSize
(int pageSize) Deprecated.SetspageSize
property.void
setPrefetchTree
(PrefetchTreeNode prefetchTree) Deprecated.void
setQualifier
(Expression qualifier) Deprecated.Sets new query qualifier.void
setStatementFetchSize
(int size) Deprecated.Sets statement's fetch size (0 for default size)void
setSuppressDistinct
(boolean suppressDistinct) Deprecated.Setsdistinct
property that determines whether this query returns distinct row.Methods inherited from class org.apache.cayenne.query.AbstractQuery
getRoot, setRoot, toString
Methods inherited from class org.apache.cayenne.query.CacheableQuery
getCacheGroup, getCacheStrategy, setCacheGroup, setCacheStrategy, useLocalCache, useLocalCache, useSharedCache, useSharedCache
-
Field Details
-
DISTINCT_PROPERTY
Deprecated.- See Also:
-
DISTINCT_DEFAULT
public static final boolean DISTINCT_DEFAULTDeprecated.- See Also:
-
qualifier
Deprecated. -
orderings
Deprecated. -
distinct
protected boolean distinctDeprecated. -
columns
Deprecated.- Since:
- 4.0
-
havingQualifier
Deprecated.- Since:
- 4.0
-
canReturnScalarValue
protected boolean canReturnScalarValueDeprecated.Flag that indicates whether this query can return single value or it should always return some complex data (Object[] for now)
Default value is true
- Since:
- 4.0
-
-
Constructor Details
-
SelectQuery
public SelectQuery()Deprecated.Creates an empty SelectQuery. -
SelectQuery
Deprecated.Creates a SelectQuery with null qualifier, for the specifed ObjEntity- Parameters:
root
- the ObjEntity this SelectQuery is for.
-
SelectQuery
Deprecated.Creates a SelectQuery for the specified ObjEntity with the given qualifier.- Parameters:
root
- the ObjEntity this SelectQuery is for.qualifier
- an Expression indicating which objects should be fetched
-
SelectQuery
Deprecated.Creates a SelectQuery for the specified ObjEntity with the given qualifier and orderings.- Parameters:
root
- the ObjEntity this SelectQuery is for.qualifier
- an Expression indicating which objects should be fetched.orderings
- defines how to order the results, may be null.- Since:
- 3.1
-
SelectQuery
Deprecated.Creates a SelectQuery that selects all objects of a given persistent class.- Parameters:
rootClass
- the Class of objects fetched by this query.
-
SelectQuery
Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.- Parameters:
rootClass
- the Class of objects fetched by this query.qualifier
- an Expression indicating which objects should be fetched.
-
SelectQuery
Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.- Parameters:
rootClass
- the Class of objects fetched by this query.qualifier
- an Expression indicating which objects should be fetched.orderings
- defines how to order the results, may be null.- Since:
- 3.1
-
SelectQuery
Deprecated.Creates a SelectQuery for the specified DbEntity.- Parameters:
root
- the DbEntity this SelectQuery is for.- Since:
- 1.1
-
SelectQuery
Deprecated.Creates a SelectQuery for the specified DbEntity with the given qualifier.- Parameters:
root
- the DbEntity this SelectQuery is for.qualifier
- an Expression indicating which objects should be fetched.- Since:
- 1.1
-
SelectQuery
Deprecated.Creates a SelectQuery for the specified DbEntity with the given qualifier and orderings.- Parameters:
root
- the DbEntity this SelectQuery is for.qualifier
- an Expression indicating which objects should be fetched.orderings
- defines how to order the results, may be null.- Since:
- 3.1
-
SelectQuery
Deprecated.Creates SelectQuery withobjEntityName
parameter. -
SelectQuery
Deprecated.Creates SelectQuery withobjEntityName
andqualifier
parameters. -
SelectQuery
Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.- Parameters:
objEntityName
- the name of the ObjEntity to fetch from.qualifier
- an Expression indicating which objects should be fetched.orderings
- defines how to order the results, may be null.- Since:
- 3.1
-
-
Method Details
-
query
Deprecated.Creates a SelectQuery that selects objects of a given persistent class.- Parameters:
rootClass
- the Class of objects fetched by this query.- Since:
- 4.0
-
query
Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.- Parameters:
rootClass
- the Class of objects fetched by this query.qualifier
- an Expression indicating which objects should be fetched.- Since:
- 4.0
-
query
public static <T> SelectQuery<T> query(Class<T> rootClass, Expression qualifier, List<? extends Ordering> orderings) Deprecated.Creates a SelectQuery that selects objects of a given persistent class that match supplied qualifier.- Parameters:
rootClass
- the Class of objects fetched by this query.qualifier
- an Expression indicating which objects should be fetched.orderings
- defines how to order the results, may be null.- Since:
- 4.0
-
dataRowQuery
Deprecated.- Since:
- 4.0
-
dataRowQuery
Deprecated.Creates a SelectQuery that selects DataRows that correspond to a given persistent class that match supplied qualifier.- Parameters:
rootClass
- the Class of objects that correspond to DataRows entity.qualifier
- an Expression indicating which objects should be fetched.- Since:
- 4.0
-
dataRowQuery
public static SelectQuery<DataRow> dataRowQuery(Class<?> rootClass, Expression qualifier, List<Ordering> orderings) Deprecated.- Since:
- 4.0
-
select
Deprecated.Description copied from interface:Select
Selects objects using provided context.Essentially the inversion of "ObjectContext.select(Select)".
-
selectOne
Deprecated.Description copied from interface:Select
Selects 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,CayenneRuntimeException
is thrown.Essentially the inversion of "ObjectContext.selectOne(Select)".
-
selectFirst
Deprecated.Description copied from interface:Select
Selects a single object using provided context. The query itself can match any number of objects, but will return only the first one. It returns null if no objects were matched.If it matched more than one object, the first object from the list is returned. This makes 'selectFirst' different from
Select.selectOne(ObjectContext)
, which would throw in this situation. 'selectFirst' is useful e.g. when the query is ordered and we only want to see the first object (e.g. "most recent news article"), etc.Selecting the first object via "Select.selectFirst(ObjectContext)" is more comprehensible than selecting via "ObjectContext.selectFirst(Select)", because implementations of "Select" set fetch size limit to one.
- Specified by:
selectFirst
in interfaceSelect<T>
-
iterate
Deprecated.Description copied from interface:Select
Creates 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)".
-
iterator
Deprecated.Description copied from interface:Select
Creates 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)".
-
batchIterator
Deprecated.Description copied from interface:Select
Creates 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:
batchIterator
in interfaceSelect<T>
-
getMetaData
Deprecated.Description copied from class:AbstractQuery
Returns default select parameters.- Specified by:
getMetaData
in interfaceQuery
- Overrides:
getMetaData
in classAbstractQuery
- Since:
- 1.2
-
route
Deprecated.Routes itself and if there are any prefetches configured, creates prefetch queries and routes them as well.- Specified by:
route
in interfaceQuery
- Overrides:
route
in classAbstractQuery
- Since:
- 1.2
-
createSQLAction
Deprecated.Calls "makeSelect" on the visitor.- Specified by:
createSQLAction
in interfaceQuery
- Specified by:
createSQLAction
in classAbstractQuery
- Since:
- 1.2
-
initWithProperties
Deprecated.Initializes query parameters using a set of properties.- Since:
- 1.1
-
queryWithParameters
Deprecated.A shortcut forqueryWithParameters(Map, boolean)
that prunes parts of qualifier that have no parameter value set. -
queryWithParameters
Deprecated.Returns a query built using this query as a prototype, using a set of parameters to build the qualifier.- See Also:
-
createQuery
Deprecated.Creates and returns a new SelectQuery built using this query as a prototype and substituting qualifier parameters with the values from the map.- Specified by:
createQuery
in interfaceParameterizedQuery
- Since:
- 1.1
-
addOrdering
Deprecated.Adds ordering specification to this query orderings. -
addOrderings
Deprecated.Adds a list of orderings. -
addOrdering
Deprecated.Adds ordering specification to this query orderings.- Since:
- 3.0
-
removeOrdering
Deprecated.Removes ordering.- Since:
- 1.1
-
getOrderings
Deprecated.Returns a list of orderings used by this query. -
clearOrderings
public void clearOrderings()Deprecated.Clears all configured orderings. -
isDistinct
public boolean isDistinct()Deprecated.Returns true if this query returns distinct rows. -
setDistinct
public void setDistinct(boolean distinct) Deprecated.Setsdistinct
property that determines whether this query returns distinct row. -
setSuppressDistinct
public void setSuppressDistinct(boolean suppressDistinct) Deprecated.Setsdistinct
property that determines whether this query returns distinct row. -
aliasPathSplits
Deprecated.Adds one or more aliases for the qualifier expression path. Aliases serve to instruct Cayenne to generate separate sets of joins for overlapping paths, that maybe needed for complex conditions. An example of an implicit splits is this method:ExpressionFactory.matchAllExp(String, Object...)
.- Since:
- 3.0
-
getPrefetchTree
Deprecated.- Since:
- 1.2
-
setPrefetchTree
Deprecated.- Since:
- 1.2
-
addPrefetch
Deprecated.Adds a prefetch with specified relationship path to the query.- Since:
- 4.0
-
addPrefetch
Deprecated.Adds a prefetch with specified relationship path to the query.- Since:
- 1.2 signature changed to return created PrefetchTreeNode.
-
clearPrefetches
public void clearPrefetches()Deprecated.Clears all stored prefetch paths. -
removePrefetch
Deprecated.Removes prefetch.- Since:
- 1.1
-
isFetchingDataRows
public boolean isFetchingDataRows()Deprecated.Returnstrue
if this query should produce a list of data rows as opposed to DataObjects,false
for DataObjects. This is a hint to QueryEngine executing this query. -
setFetchingDataRows
public void setFetchingDataRows(boolean flag) Deprecated.since 4.0, usedataRowQuery(Class, Expression)
to create DataRow query instead.Sets query result type. Ifflag
parameter istrue
, then results will be in the form of data rows.Note that if the root of this query is a
DbEntity
, this setting has no effect, and data rows are always fetched. -
getFetchOffset
public int getFetchOffset()Deprecated.Returns the fetchOffset.- Since:
- 3.0
-
getFetchLimit
public int getFetchLimit()Deprecated.Returns the fetchLimit. -
setFetchLimit
public void setFetchLimit(int fetchLimit) Deprecated.Sets the fetchLimit. -
setFetchOffset
public void setFetchOffset(int fetchOffset) Deprecated.- Since:
- 3.0
-
getPageSize
public int getPageSize()Deprecated.ReturnspageSize
property. See setPageSize for more details. -
setPageSize
public void setPageSize(int pageSize) Deprecated.SetspageSize
property. By setting a page size, the Collection returned by performing a query will return hollow DataObjects. This is considerably faster and uses a tiny fraction of the memory compared to a non-paged query when large numbers of objects are returned in the result. When a hollow DataObject is accessed all DataObjects on the same page will be faulted into memory. There will be a small delay when faulting objects while the data is fetched from the data source, but otherwise you do not need to do anything special to access data in hollow objects. The first page is always faulted into memory immediately.- Parameters:
pageSize
- The pageSize to set
-
setStatementFetchSize
public void setStatementFetchSize(int size) Deprecated.Sets statement's fetch size (0 for default size)- Since:
- 3.0
-
getStatementFetchSize
public int getStatementFetchSize()Deprecated.- Returns:
- statement's fetch size
- Since:
- 3.0
-
setQualifier
Deprecated.Sets new query qualifier. -
getQualifier
Deprecated.Returns query qualifier. -
andQualifier
Deprecated.Adds specified qualifier to the existing qualifier joining it using "AND". -
orQualifier
Deprecated.Adds specified qualifier to the existing qualifier joining it using "OR". -
setColumns
Deprecated.- Since:
- 4.0
- See Also:
-
setColumns
Deprecated.- Since:
- 4.0
-
setCanReturnScalarValue
public void setCanReturnScalarValue(boolean canReturnScalarValue) Deprecated.Flag that indicates whether this query can return single value or it should always return some complex data (Object[] for now)
Default value is true
- Parameters:
canReturnScalarValue
- can this query return single value- Since:
- 4.0
- See Also:
-
canReturnScalarValue
public boolean canReturnScalarValue()Deprecated.- Returns:
- can this query return single value
- Since:
- 4.0
-
getColumns
Deprecated.- Since:
- 4.0
-
setHavingQualifier
Deprecated.Sets new query HAVING qualifier.- Since:
- 4.0
-
getHavingQualifier
Deprecated.Returns query HAVING qualifier.- Since:
- 4.0
-
andHavingQualifier
Deprecated.Adds specified HAVING qualifier to the existing HAVING qualifier joining it using "AND".- Since:
- 4.0
-
orHavingQualifier
Deprecated.Adds specified HAVING qualifier to the existing HAVING qualifier joining it using "OR".- Since:
- 4.0
-
getBaseMetaData
protected org.apache.cayenne.query.BaseQueryMetadata getBaseMetaData()Deprecated.- Specified by:
getBaseMetaData
in classCacheableQuery
-
ObjectSelect