Class MappedSelect<T>
- All Implemented Interfaces:
Serializable
,Query
,Select<T>
- Since:
- 4.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Integer
protected Integer
protected boolean
protected Integer
protected Integer
protected Integer
Fields inherited from class org.apache.cayenne.query.AbstractMappedQuery
params, queryName
Fields inherited from class org.apache.cayenne.query.IndirectQuery
dataMap, lastResolver, name, replacementQuery
-
Constructor Summary
ModifierConstructorDescriptionprotected
MappedSelect
(String queryName) protected
MappedSelect
(String queryName, Class<T> resultClass) -
Method Summary
Modifier and TypeMethodDescriptionbatchIterator
(ObjectContext context, int size) Creates a ResultBatchIterator based on the provided context and batch size.protected Query
createReplacementQuery
(EntityResolver resolver) Creates a substitute query.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.iterator
(ObjectContext context) Creates a ResultIterator based on the provided context.limit
(int fetchLimit) Resets query fetch limit - a parameter that defines max number of objects that should be ever be fetched from the database.offset
(int fetchOffset) Resets query fetch offset - a parameter that defines how many objects should be skipped when reading data from the database.pageSize
(int pageSize) Resets query page size.static MappedSelect
<?> Loads query with the given name from the mapping configuration.static <T> MappedSelect
<T> Loads query with the given name, which selects objects of a given persistent class, from the mapping configuration.queryTimeout
(int timeout) Sets query timeout for the PreparedStatement generated for this query.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.statementFetchSize
(int statementFetchSize) Sets fetch size of the PreparedStatement generated for this query.Methods inherited from class org.apache.cayenne.query.AbstractMappedQuery
name
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
-
Field Details
-
resultClass
-
fetchLimit
-
fetchOffset
-
statementFetchSize
-
queryTimeout
-
pageSize
-
forceNoCache
protected boolean forceNoCache
-
-
Constructor Details
-
MappedSelect
-
MappedSelect
-
-
Method Details
-
query
Loads query with the given name, which selects objects of a given persistent class, from the mapping configuration.- Parameters:
queryName
- name of the mapped queryrootClass
- the Class of objects fetched by this query
-
query
Loads query with the given name from the mapping configuration.- Parameters:
queryName
- name of the mapped query
-
limit
Resets query fetch limit - a parameter that defines max number of objects that should be ever be fetched from the database. -
offset
Resets query fetch offset - a parameter that defines how many objects should be skipped when reading data from the database. -
statementFetchSize
Sets fetch size of the PreparedStatement generated for this query. Only non-negative values would change the default size.- See Also:
-
queryTimeout
Sets query timeout for the PreparedStatement generated for this query.- Since:
- 4.2
- See Also:
-
pageSize
Resets query page size. A non-negative page size enables query result pagination that saves memory and processing time for large lists if only parts of the result are ever going to be accessed. -
forceNoCache
Forces query cache to be refreshed during the execution of this query. -
params
- Overrides:
params
in classAbstractMappedQuery
-
param
- Overrides:
param
in classAbstractMappedQuery
-
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>
-
createReplacementQuery
Description copied from class:IndirectQuery
Creates a substitute query. An implementor is free to provide an arbitrary replacement query.- Overrides:
createReplacementQuery
in classAbstractMappedQuery
-