public class SelectQuery extends QualifiedQuery implements ParameterizedQuery, XMLSerializable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
distinct |
static boolean |
DISTINCT_DEFAULT |
static String |
DISTINCT_PROPERTY |
protected List<Ordering> |
orderings |
qualifierdataMap, name, root| Constructor and Description |
|---|
SelectQuery()
Creates an empty SelectQuery.
|
SelectQuery(Class<?> rootClass)
Creates a SelectQuery that selects all objects of a given persistent class.
|
SelectQuery(Class<?> rootClass,
Expression qualifier)
Creates a SelectQuery that selects objects of a given persistent class that match
supplied qualifier.
|
SelectQuery(Class<?> rootClass,
Expression qualifier,
List<Ordering> orderings)
Creates a SelectQuery that selects objects of a given persistent class that match
supplied qualifier.
|
SelectQuery(DbEntity root)
Creates a SelectQuery for the specified DbEntity.
|
SelectQuery(DbEntity root,
Expression qualifier)
Creates a SelectQuery for the specified DbEntity with the given qualifier.
|
SelectQuery(DbEntity root,
Expression qualifier,
List<Ordering> orderings)
Creates a SelectQuery for the specified DbEntity with the given qualifier and orderings.
|
SelectQuery(ObjEntity root)
Creates a SelectQuery with null qualifier, for the specifed ObjEntity
|
SelectQuery(ObjEntity root,
Expression qualifier)
Creates a SelectQuery for the specified ObjEntity with the given qualifier.
|
SelectQuery(ObjEntity root,
Expression qualifier,
List<Ordering> orderings)
Creates a SelectQuery for the specified ObjEntity with the given
qualifier and orderings.
|
SelectQuery(String objEntityName)
Creates SelectQuery with
objEntityName parameter. |
SelectQuery(String objEntityName,
Expression qualifier)
Creates SelectQuery with
objEntityName and qualifier
parameters. |
SelectQuery(String objEntityName,
Expression qualifier,
List<Ordering> orderings)
Creates a SelectQuery that selects objects of a given persistent class that match
supplied qualifier.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOrdering(Ordering ordering)
Adds ordering specification to this query orderings.
|
void |
addOrdering(String sortPathSpec,
SortOrder order)
Adds ordering specification to this query orderings.
|
void |
addOrderings(List<Ordering> orderings)
Adds a list of orderings.
|
PrefetchTreeNode |
addPrefetch(String prefetchPath)
Adds a prefetch with specified relationship path to the query.
|
void |
aliasPathSplits(String path,
String... aliases)
Adds one or more aliases for the qualifier expression path.
|
void |
clearOrderings()
Clears all configured orderings.
|
void |
clearPrefetches()
Clears all stored prefetch paths.
|
Query |
createQuery(Map<String,?> parameters)
Creates and returns a new SelectQuery built using this query as a prototype and
substituting qualifier parameters with the values from the map.
|
SQLAction |
createSQLAction(SQLActionVisitor visitor)
Calls "makeSelect" on the visitor.
|
void |
encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided PrintWriter.
|
String[] |
getCacheGroups() |
QueryCacheStrategy |
getCacheStrategy() |
int |
getFetchLimit()
Returns the fetchLimit.
|
int |
getFetchOffset()
Returns the fetchOffset.
|
QueryMetadata |
getMetaData(EntityResolver resolver)
Returns default select parameters.
|
List<Ordering> |
getOrderings()
Returns a list of orderings used by this query.
|
int |
getPageSize()
Returns
pageSize property. |
PrefetchTreeNode |
getPrefetchTree() |
int |
getStatementFetchSize() |
void |
initWithProperties(Map<String,?> properties)
Initializes query parameters using a set of properties.
|
boolean |
isDistinct()
Returns true if this query returns distinct rows.
|
boolean |
isFetchingDataRows()
Returns
true if this query should produce a list of data rows as
opposed to DataObjects, false for DataObjects. |
SelectQuery |
queryWithParameters(Map<String,?> parameters)
A shortcut for
queryWithParameters(Map, boolean)that prunes parts of
qualifier that have no parameter value set. |
SelectQuery |
queryWithParameters(Map<String,?> parameters,
boolean pruneMissing)
Returns a query built using this query as a prototype, using a set of parameters to
build the qualifier.
|
void |
removeOrdering(Ordering ordering)
Removes ordering.
|
void |
removePrefetch(String prefetchPath)
Removes prefetch.
|
void |
route(QueryRouter router,
EntityResolver resolver,
Query substitutedQuery)
Routes itself and if there are any prefetches configured, creates prefetch queries
and routes them as well.
|
void |
setCacheGroups(String... cacheGroups) |
void |
setCacheStrategy(QueryCacheStrategy strategy) |
void |
setDistinct(boolean distinct)
Sets
distinct property that determines whether this query returns
distinct row. |
void |
setFetchingDataRows(boolean flag)
Sets query result type.
|
void |
setFetchLimit(int fetchLimit)
Sets the fetchLimit.
|
void |
setFetchOffset(int fetchOffset) |
void |
setPageSize(int pageSize)
Sets
pageSize property. |
void |
setPrefetchTree(PrefetchTreeNode prefetchTree) |
void |
setStatementFetchSize(int size)
Sets statement's fetch size (0 for default size)
|
andQualifier, getQualifier, orQualifier, setQualifieracceptVisitor, getDataMap, getName, getRoot, setDataMap, setName, setRoot, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDataMap, getNameacceptVisitorpublic static final String DISTINCT_PROPERTY
public static final boolean DISTINCT_DEFAULT
protected boolean distinct
public SelectQuery()
public SelectQuery(ObjEntity root)
root - the ObjEntity this SelectQuery is for.public SelectQuery(ObjEntity root, Expression qualifier)
root - the ObjEntity this SelectQuery is for.qualifier - an Expression indicating which objects should be fetchedpublic SelectQuery(ObjEntity root, Expression qualifier, List<Ordering> orderings)
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.public SelectQuery(Class<?> rootClass)
rootClass - the Class of objects fetched by this query.public SelectQuery(Class<?> rootClass, Expression qualifier)
rootClass - the Class of objects fetched by this query.qualifier - an Expression indicating which objects should be fetched.public SelectQuery(Class<?> rootClass, Expression qualifier, List<Ordering> orderings)
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.public SelectQuery(DbEntity root)
root - the DbEntity this SelectQuery is for.public SelectQuery(DbEntity root, Expression qualifier)
root - the DbEntity this SelectQuery is for.qualifier - an Expression indicating which objects should be fetched.public SelectQuery(DbEntity root, Expression qualifier, List<Ordering> orderings)
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.public SelectQuery(String objEntityName)
objEntityName parameter.public SelectQuery(String objEntityName, Expression qualifier)
objEntityName and qualifier
parameters.public SelectQuery(String objEntityName, Expression qualifier, List<Ordering> orderings)
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.public QueryMetadata getMetaData(EntityResolver resolver)
AbstractQuerygetMetaData in interface QuerygetMetaData in class AbstractQuerypublic void route(QueryRouter router, EntityResolver resolver, Query substitutedQuery)
route in interface Queryroute in class AbstractQuerypublic SQLAction createSQLAction(SQLActionVisitor visitor)
createSQLAction in interface QuerycreateSQLAction in class AbstractQuerypublic void initWithProperties(Map<String,?> properties)
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML in interface XMLSerializablepublic SelectQuery queryWithParameters(Map<String,?> parameters)
queryWithParameters(Map, boolean)that prunes parts of
qualifier that have no parameter value set.public SelectQuery queryWithParameters(Map<String,?> parameters, boolean pruneMissing)
parameter substitution.public Query createQuery(Map<String,?> parameters)
createQuery in interface ParameterizedQuerypublic void addOrdering(Ordering ordering)
public void addOrdering(String sortPathSpec, SortOrder order)
public void removeOrdering(Ordering ordering)
public void clearOrderings()
public boolean isDistinct()
public void setDistinct(boolean distinct)
distinct property that determines whether this query returns
distinct row.public void aliasPathSplits(String path, String... aliases)
ExpressionFactory.matchAllExp(String, Object...).public PrefetchTreeNode getPrefetchTree()
public void setPrefetchTree(PrefetchTreeNode prefetchTree)
public PrefetchTreeNode addPrefetch(String prefetchPath)
public void clearPrefetches()
public void removePrefetch(String prefetchPath)
public boolean isFetchingDataRows()
true 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.public void setFetchingDataRows(boolean flag)
flag parameter is true, 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.
public QueryCacheStrategy getCacheStrategy()
public void setCacheStrategy(QueryCacheStrategy strategy)
public String[] getCacheGroups()
public void setCacheGroups(String... cacheGroups)
public int getFetchOffset()
public int getFetchLimit()
public void setFetchLimit(int fetchLimit)
public void setFetchOffset(int fetchOffset)
public int getPageSize()
pageSize property. See setPageSize for more details.public void setPageSize(int pageSize)
pageSize 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.pageSize - The pageSize to setpublic void setStatementFetchSize(int size)
public int getStatementFetchSize()
Copyright © 2001–2018 Apache Cayenne. All rights reserved.