Class MappedSelect<T>
java.lang.Object
org.apache.cayenne.query.IndirectQuery
org.apache.cayenne.query.AbstractMappedQuery
org.apache.cayenne.query.MappedSelect<T>
A query that represents a named parameterized selecting query stored in the mapping. The
actual query is resolved during execution.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Integerprotected Integerprotected booleanprotected Integerprotected Integerprotected IntegerFields inherited from class AbstractMappedQuery
params, queryNameFields inherited from class IndirectQuery
dataMap, lastResolver, name, replacementQuery -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMappedSelect(String queryName) protectedMappedSelect(String queryName, Class<T> resultClass) -
Method Summary
Modifier and TypeMethodDescriptionprotected QuerycreateReplacementQuery(EntityResolver resolver) Creates a substitute query.Forces query cache to be refreshed during the execution of this query.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.selectFirst(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 AbstractMappedQuery
nameMethods inherited from class IndirectQuery
createSQLAction, getMetaData, getReplacementQuery, routeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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. Any non-zero value is passed to the driver as is; 0 (the default) leaves the fetch size to the adapter and the driver. A negative value is only meaningful for drivers that give it a special meaning, such asInteger.MIN_VALUEfor streaming on MySQL.- 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:
paramsin classAbstractMappedQuery
-
param
- Overrides:
paramin classAbstractMappedQuery
-
selectFirst
Description copied from interface:SelectSelects 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:
selectFirstin interfaceSelect<T>
-
createReplacementQuery
Description copied from class:IndirectQueryCreates a substitute query. An implementor is free to provide an arbitrary replacement query.- Overrides:
createReplacementQueryin classAbstractMappedQuery
-