Class SelectById<T>
- All Implemented Interfaces:
Serializable
,Query
,Select<T>
- Since:
- 4.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
protected static class
protected static class
protected static interface
protected static class
protected static class
-
Field Summary
Fields inherited from class org.apache.cayenne.query.IndirectQuery
dataMap, lastResolver, name, replacementQuery
-
Constructor Summary
ModifierConstructorDescriptionprotected
SelectById
(SelectById.QueryRoot root, SelectById.IdSpec idSpec) protected
SelectById
(SelectById.QueryRoot root, SelectById.IdSpec idSpec, boolean fetchingDataRows) -
Method Summary
Modifier and TypeMethodDescriptionbatchIterator
(ObjectContext context, int size) Creates a ResultBatchIterator based on the provided context and batch size.cacheGroup
(String cacheGroup) cacheStrategy
(QueryCacheStrategy strategy) cacheStrategy
(QueryCacheStrategy strategy, String cacheGroup) protected Query
createReplacementQuery
(EntityResolver resolver) Creates a substitute query.static SelectById
<DataRow> dataRowQuery
(Class<?> entityType, Object id) static SelectById
<DataRow> dataRowQuery
(Class<?> entityType, Object firstId, Object... otherIds) static SelectById
<DataRow> dataRowQuery
(Class<?> entityType, Map<String, ?> id) static SelectById
<DataRow> static SelectById
<DataRow> dataRowQuery
(ObjectId id) static SelectById
<DataRow> dataRowQuery
(ObjectId firstId, ObjectId... otherIds) boolean
void
iterate
(ObjectContext context, ResultIteratorCallback<T> callback) Creates a ResultIterator based on the provided context and passes it to a callback for processing.iterator
(ObjectContext context) Creates a ResultIterator based on the provided context.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.Merges a prefetch path with specified semantics into the query prefetch tree.prefetch
(PrefetchTreeNode prefetch) Merges prefetch into the query prefetch tree.static <T> SelectById
<T> static <T> SelectById
<T> static <T> SelectById
<T> query
(Class<T> entityType, Collection<Object> ids) static <T> SelectById
<T> static <T> SelectById
<T> static <T> SelectById
<T> static <T> SelectById
<T> select
(ObjectContext context) Selects objects using provided context.selectFirst
(ObjectContext context) Selects a single object using provided context.selectOne
(ObjectContext context) Selects a single object using provided context.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.Methods inherited from class org.apache.cayenne.query.IndirectQuery
createSQLAction, getMetaData, getReplacementQuery, route
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.cayenne.query.Query
createSQLAction, getMetaData, route
-
Constructor Details
-
SelectById
-
SelectById
-
-
Method Details
-
query
-
query
-
query
-
query
- Since:
- 4.2
-
query
- Since:
- 4.2
-
query
@SafeVarargs public static <T> SelectById<T> query(Class<T> entityType, Map<String, ?> firstId, Map<String, ?>... otherIds) - Since:
- 4.2
-
query
- Since:
- 4.2
-
dataRowQuery
-
dataRowQuery
-
dataRowQuery
-
dataRowQuery
public static SelectById<DataRow> dataRowQuery(Class<?> entityType, Object firstId, Object... otherIds) - Since:
- 4.2
-
dataRowQuery
@SafeVarargs public static SelectById<DataRow> dataRowQuery(Class<?> entityType, Map<String, ?> firstId, Map<String, ?>... otherIds) - Since:
- 4.2
-
dataRowQuery
- Since:
- 4.2
-
select
Description copied from interface:Select
Selects objects using provided context.Essentially the inversion of "ObjectContext.select(Select)".
-
selectOne
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
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
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
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
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>
-
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, cacheGroup);
-
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
-
cacheStrategy
-
cacheStrategy
-
getCacheGroup
-
cacheGroup
-
isFetchingDataRows
public boolean isFetchingDataRows() -
prefetch
Merges prefetch into the query prefetch tree.- Returns:
- this object
-
prefetch
Merges a prefetch path with specified semantics into the query prefetch tree.- Returns:
- this object
-
getPrefetches
-
createReplacementQuery
Description copied from class:IndirectQuery
Creates a substitute query. An implementor is free to provide an arbitrary replacement query.- Specified by:
createReplacementQuery
in classIndirectQuery
-