public class SelectById<T> extends IndirectQuery implements Select<T>
dataMap, lastResolver, name, replacementQuery
Constructor and Description |
---|
SelectById() |
Modifier and Type | Method and Description |
---|---|
ResultBatchIterator<T> |
batchIterator(ObjectContext context,
int size)
Creates a ResultBatchIterator based on the provided context and batch
size.
|
SelectById<T> |
cacheGroup(String cacheGroup) |
SelectById<T> |
cacheStrategy(QueryCacheStrategy strategy) |
SelectById<T> |
cacheStrategy(QueryCacheStrategy strategy,
String cacheGroup) |
protected Query |
createReplacementQuery(EntityResolver resolver)
Creates a substitute query.
|
static SelectById<DataRow> |
dataRowQuery(Class<?> entityType,
Map<String,Object> id) |
static SelectById<DataRow> |
dataRowQuery(Class<?> entityType,
Object id) |
static SelectById<DataRow> |
dataRowQuery(ObjectId id) |
String |
getCacheGroup() |
QueryCacheStrategy |
getCacheStrategy() |
PrefetchTreeNode |
getPrefetches() |
boolean |
isFetchingDataRows() |
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.
|
SelectById<T> |
localCache()
Instructs Cayenne to look for query results in the "local" cache when
running the query.
|
SelectById<T> |
localCache(String cacheGroup)
Instructs Cayenne to look for query results in the "local" cache when
running the query.
|
SelectById<T> |
prefetch(PrefetchTreeNode prefetch)
Merges prefetch into the query prefetch tree.
|
SelectById<T> |
prefetch(String path,
int semantics)
Merges a prefetch path with specified semantics into the query prefetch
tree.
|
static <T> SelectById<T> |
query(Class<T> entityType,
Map<String,?> id) |
static <T> SelectById<T> |
query(Class<T> entityType,
Object id) |
static <T> SelectById<T> |
query(Class<T> entityType,
ObjectId id) |
protected ObjEntity |
resolveEntity(EntityResolver resolver) |
protected Map<String,?> |
resolveId(ObjEntity entity) |
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.
|
SelectById<T> |
sharedCache()
Instructs Cayenne to look for query results in the "shared" cache when
running the query.
|
SelectById<T> |
sharedCache(String cacheGroup)
Instructs Cayenne to look for query results in the "shared" cache when
running the query.
|
createSQLAction, getDataMap, getMetaData, getName, getReplacementQuery, route, setDataMap, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createSQLAction, getDataMap, getMetaData, getName, route
public static <T> SelectById<T> query(Class<T> entityType, Object id)
public static <T> SelectById<T> query(Class<T> entityType, Map<String,?> id)
public static <T> SelectById<T> query(Class<T> entityType, ObjectId id)
public static SelectById<DataRow> dataRowQuery(Class<?> entityType, Object id)
public static SelectById<DataRow> dataRowQuery(Class<?> entityType, Map<String,Object> id)
public static SelectById<DataRow> dataRowQuery(ObjectId id)
public List<T> select(ObjectContext context)
Select
Essentially the inversion of "ObjectContext.select(Select)".
public T selectOne(ObjectContext context)
Select
CayenneRuntimeException
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)
Select
Essentially the inversion of "ObjectContext.iterate(Select, ResultIteratorCallback)".
public ResultIterator<T> iterator(ObjectContext context)
Select
Select.iterate(ObjectContext, ResultIteratorCallback)
as an
alternative.
Essentially the inversion of "ObjectContext.iterator(Select)".
public ResultBatchIterator<T> batchIterator(ObjectContext context, int size)
Select
batchIterator
in interface Select<T>
public SelectById<T> localCache(String cacheGroup)
query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE, cacheGroup);
public SelectById<T> localCache()
query.cacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
public SelectById<T> sharedCache(String cacheGroup)
query.cacheStrategy(QueryCacheStrategy.SHARED_CACHE, cacheGroup);
public SelectById<T> sharedCache()
query.cacheStrategy(QueryCacheStrategy.SHARED_CACHE);
public QueryCacheStrategy getCacheStrategy()
public SelectById<T> cacheStrategy(QueryCacheStrategy strategy)
public SelectById<T> cacheStrategy(QueryCacheStrategy strategy, String cacheGroup)
public String getCacheGroup()
public SelectById<T> cacheGroup(String cacheGroup)
public boolean isFetchingDataRows()
public SelectById<T> prefetch(PrefetchTreeNode prefetch)
public SelectById<T> prefetch(String path, int semantics)
public PrefetchTreeNode getPrefetches()
protected Query createReplacementQuery(EntityResolver resolver)
IndirectQuery
createReplacementQuery
in class IndirectQuery
protected ObjEntity resolveEntity(EntityResolver resolver)
Copyright © 2001–2018 Apache Cayenne. All rights reserved.