public class MappedSelect<T> extends AbstractMappedQuery implements Select<T>
| Modifier and Type | Field and Description |
|---|---|
protected Integer |
fetchLimit |
protected Integer |
fetchOffset |
protected boolean |
forceNoCache |
protected Integer |
pageSize |
protected Class<T> |
resultClass |
protected Integer |
statementFetchSize |
params, queryNamedataMap, lastResolver, name, replacementQuery| Modifier | Constructor and Description |
|---|---|
protected |
MappedSelect(String queryName) |
protected |
MappedSelect(String queryName,
Class<T> resultClass) |
| Modifier and Type | Method and Description |
|---|---|
ResultBatchIterator<T> |
batchIterator(ObjectContext context,
int size)
Creates a ResultBatchIterator based on the provided context and batch
size.
|
protected Query |
createReplacementQuery(EntityResolver resolver)
Creates a substitute query.
|
MappedSelect<T> |
forceNoCache()
Forces query cache to be refreshed during the execution of this query.
|
void |
iterate(ObjectContext context,
ResultIteratorCallback<T> callback)
Creates a ResultIterator based on the provided context and passes it to a
callback for processing.
|
ResultIterator<T> |
iterator(ObjectContext context)
Creates a ResultIterator based on the provided context.
|
MappedSelect<T> |
limit(int fetchLimit)
Resets query fetch limit - a parameter that defines max number of objects
that should be ever be fetched from the database.
|
MappedSelect<T> |
offset(int fetchOffset)
Resets query fetch offset - a parameter that defines how many objects
should be skipped when reading data from the database.
|
MappedSelect<T> |
pageSize(int pageSize)
Resets query page size.
|
MappedSelect<T> |
param(String name,
Object value) |
MappedSelect<T> |
params(Map<String,?> parameters) |
static MappedSelect<?> |
query(String queryName)
Loads query with the given name from the mapping configuration.
|
static <T> MappedSelect<T> |
query(String queryName,
Class<T> rootClass)
Loads query with the given name, which selects objects of a given persistent class,
from the mapping configuration.
|
List<T> |
select(ObjectContext context)
Selects objects using provided context.
|
T |
selectFirst(ObjectContext context)
Selects a single object using provided context.
|
T |
selectOne(ObjectContext context)
Selects a single object using provided context.
|
MappedSelect<T> |
statementFetchSize(int statementFetchSize)
Sets fetch size of the PreparedStatement generated for this query.
|
namecreateSQLAction, getDataMap, getMetaData, getName, getReplacementQuery, route, setDataMap, setNameclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateSQLAction, getDataMap, getMetaData, getName, routeprotected Integer fetchLimit
protected Integer fetchOffset
protected Integer statementFetchSize
protected Integer pageSize
protected boolean forceNoCache
protected MappedSelect(String queryName)
public static <T> MappedSelect<T> query(String queryName, Class<T> rootClass)
queryName - name of the mapped queryrootClass - the Class of objects fetched by this querypublic static MappedSelect<?> query(String queryName)
queryName - name of the mapped querypublic MappedSelect<T> limit(int fetchLimit)
public MappedSelect<T> offset(int fetchOffset)
public MappedSelect<T> statementFetchSize(int statementFetchSize)
Statement.setFetchSize(int)public MappedSelect<T> pageSize(int pageSize)
public MappedSelect<T> forceNoCache()
public MappedSelect<T> params(Map<String,?> parameters)
params in class AbstractMappedQuerypublic MappedSelect<T> param(String name, Object value)
param in class AbstractMappedQuerypublic List<T> select(ObjectContext context)
SelectEssentially the inversion of "ObjectContext.select(Select)".
public T selectOne(ObjectContext context)
SelectCayenneRuntimeException is thrown.
Essentially the inversion of "ObjectContext.selectOne(Select)".
public T selectFirst(ObjectContext context)
Select
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.
selectFirst in interface Select<T>public void iterate(ObjectContext context, ResultIteratorCallback<T> callback)
SelectEssentially the inversion of "ObjectContext.iterate(Select, ResultIteratorCallback)".
public ResultIterator<T> iterator(ObjectContext context)
SelectSelect.iterate(ObjectContext, ResultIteratorCallback) as an
alternative.
Essentially the inversion of "ObjectContext.iterator(Select)".
public ResultBatchIterator<T> batchIterator(ObjectContext context, int size)
SelectbatchIterator in interface Select<T>protected Query createReplacementQuery(EntityResolver resolver)
IndirectQuerycreateReplacementQuery in class AbstractMappedQueryCopyright © 2001–2023 Apache Cayenne. All rights reserved.