Class ProcedureQuery
- All Implemented Interfaces:
- Serializable,- ParameterizedQuery,- Query
Execution with DataContext
Reading OUT parameters
If a ProcedureQuery has OUT parameters, they are wrapped in a separate List in the query result. Such list will contain a single Map with OUT parameter values.
Using ProcedureQuery as a GenericSelectQuery
 Executing ProcedureQuery via
 DataContext.performQuery(Query) makes sense only if
 the stored procedure returns a single result set (or alternatively returns a result via
 OUT parameters and no other result sets). It is still OK if data modification occurs as
 a side effect. However if the query returns more then one result set, a more generic
 form should be used:
 DataContext.performGenericQuery(Query).
 
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringprotected CapsStrategyprotected Class<?>protected List<ColumnDescriptor[]>protected StringFields inherited from class org.apache.cayenne.query.AbstractQueryrootFields inherited from class org.apache.cayenne.query.CacheableQuerylogger
- 
Constructor SummaryConstructorsConstructorDescriptionCreates an empty procedure query.ProcedureQuery(String procedureName) Creates a ProcedureQuery based on a stored procedure.ProcedureQuery(String procedureName, Class<?> resultType) ProcedureQuery(Procedure procedure) Creates a ProcedureQuery based on a Procedure object.ProcedureQuery(Procedure procedure, Class<?> resultType) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddParameter(String name, Object value) Adds a named parameter to the internal map of parameters.addPrefetch(String prefetchPath) Adds a prefetch.voidaddPrefetches(Collection<String> prefetches) Adds all prefetches from a provided collection.voidaddResultDescriptor(ColumnDescriptor[] descriptor) Adds a descriptor for a single ResultSet.voidCleans up all configured parameters.voidClears all prefetches.createQuery(Map<String, ?> parameters) Creates and returns a new ProcedureQuery built using this query as a prototype and substituting template parameters with the values from the map.createSQLAction(SQLActionVisitor visitor) Calls "makeProcedure" on the visitor.protected org.apache.cayenne.query.BaseQueryMetadataintintgetMetaData(EntityResolver resolver) Returns default select parameters.intReturns a map of procedure parameters.intReturns a List of descriptors for query ResultSets in the order they are returned by the stored procedure.intvoidinitWithProperties(Map<String, ?> properties) Initializes query parameters using a set of properties.booleanvoidremoveParameter(String name) voidremovePrefetch(String prefetch) voidremoveResultDescriptor(ColumnDescriptor[] descriptor) Removes result descriptor from the list of descriptors.voidsetColumnNamesCapitalization(CapsStrategy columnNameCapitalization) voidsetFetchingDataRows(boolean flag) voidsetFetchLimit(int fetchLimit) voidsetFetchOffset(int fetchOffset) voidsetPageSize(int pageSize) voidsetParameters(Map<String, ?> parameters) Sets a map of parameters.voidsetQueryTimeout(int timeout) Set's query timeoutvoidsetResultEntityName(String resultEntityName) voidsetStatementFetchSize(int size) Sets statement's fetch size (0 for no default size)Methods inherited from class org.apache.cayenne.query.AbstractQuerygetRoot, route, setRoot, toStringMethods inherited from class org.apache.cayenne.query.CacheableQuerygetCacheGroup, getCacheStrategy, setCacheGroup, setCacheStrategy, useLocalCache, useLocalCache, useSharedCache, useSharedCache
- 
Field Details- 
COLUMN_NAME_CAPITALIZATION_PROPERTY- See Also:
 
- 
resultEntityName- Since:
- 1.2
 
- 
resultClass- Since:
- 1.2
 
- 
columnNamesCapitalization
- 
parameters
- 
resultDescriptors- Since:
- 1.2
 
 
- 
- 
Constructor Details- 
ProcedureQuerypublic ProcedureQuery()Creates an empty procedure query. The query would fetch DataRows. Fetching Persistent objects can be achieved either by usingProcedureQuery(String, Class)constructor or by callingsetFetchingDataRows(boolean)andsetResultEntityName(String)methods.
- 
ProcedureQueryCreates a ProcedureQuery based on a Procedure object. The query would fetch DataRows. Fetching Persistent objects can be achieved either by usingProcedureQuery(String, Class)constructor or by callingsetFetchingDataRows(boolean)andsetResultEntityName(String)methods.
- 
ProcedureQueryCreates a ProcedureQuery based on a stored procedure. The query would fetch DataRows. Fetching Persistent objects can be achieved either by usingProcedureQuery(String, Class)constructor or by callingsetFetchingDataRows(boolean)andsetResultEntityName(String)methods.- Parameters:
- procedureName- A name of the stored procedure. For this query to work, a procedure with this name must be mapped in Cayenne.
 
- 
ProcedureQuery- Since:
- 1.1
 
- 
ProcedureQuery- Since:
- 1.1
 
 
- 
- 
Method Details- 
getMetaDataDescription copied from class:AbstractQueryReturns default select parameters.- Specified by:
- getMetaDatain interface- Query
- Overrides:
- getMetaDatain class- AbstractQuery
- Since:
- 1.2
 
- 
getResultDescriptorsReturns a List of descriptors for query ResultSets in the order they are returned by the stored procedure.Note that if a procedure returns ResultSet in an OUT parameter, it is returned prior to any other result sets (though in practice database engines usually support only one mechanism for returning result sets. - Since:
- 1.2
 
- 
addResultDescriptorAdds a descriptor for a single ResultSet. More than one descriptor can be added by calling this method multiple times in the order of described ResultSet appearance in the procedure results.- Since:
- 1.2
 
- 
removeResultDescriptorRemoves result descriptor from the list of descriptors.- Since:
- 1.2
 
- 
createSQLActionCalls "makeProcedure" on the visitor.- Specified by:
- createSQLActionin interface- Query
- Specified by:
- createSQLActionin class- AbstractQuery
- Since:
- 1.2
 
- 
initWithPropertiesInitializes query parameters using a set of properties.- Since:
- 1.1
 
- 
createQueryCreates and returns a new ProcedureQuery built using this query as a prototype and substituting template parameters with the values from the map.- Specified by:
- createQueryin interface- ParameterizedQuery
- Since:
- 1.1
 
- 
getBaseMetaDataprotected org.apache.cayenne.query.BaseQueryMetadata getBaseMetaData()- Specified by:
- getBaseMetaDatain class- CacheableQuery
 
- 
getFetchLimitpublic int getFetchLimit()
- 
setFetchLimitpublic void setFetchLimit(int fetchLimit) 
- 
getFetchOffsetpublic int getFetchOffset()- Since:
- 3.0
 
- 
setFetchOffsetpublic void setFetchOffset(int fetchOffset) - Since:
- 3.0
 
- 
getPageSizepublic int getPageSize()
- 
setPageSizepublic void setPageSize(int pageSize) 
- 
setFetchingDataRowspublic void setFetchingDataRows(boolean flag) 
- 
isFetchingDataRowspublic boolean isFetchingDataRows()
- 
addParameterAdds a named parameter to the internal map of parameters.- Since:
- 1.1
 
- 
removeParameter- Since:
- 1.1
 
- 
getParametersReturns a map of procedure parameters.- Since:
- 1.1
 
- 
setParametersSets a map of parameters.- Since:
- 1.1
 
- 
clearParameterspublic void clearParameters()Cleans up all configured parameters.- Since:
- 1.1
 
- 
getPrefetchTree- Since:
- 1.2
 
- 
addPrefetchAdds a prefetch.- Since:
- 1.2
 
- 
removePrefetch- Since:
- 1.2
 
- 
addPrefetchesAdds all prefetches from a provided collection.- Since:
- 1.2
 
- 
clearPrefetchespublic void clearPrefetches()Clears all prefetches.- Since:
- 1.2
 
- 
getResultEntityName- Since:
- 1.2
 
- 
setResultEntityName- Since:
- 1.2
 
- 
getColumnNamesCapitalization- Since:
- 3.0
 
- 
setColumnNamesCapitalization- Since:
- 3.0
 
- 
setStatementFetchSizepublic void setStatementFetchSize(int size) Sets statement's fetch size (0 for no default size)- Since:
- 3.0
 
- 
getStatementFetchSizepublic int getStatementFetchSize()- Returns:
- statement's fetch size
- Since:
- 3.0
 
- 
getQueryTimeoutpublic int getQueryTimeout()- Returns:
- query timeout
- Since:
- 4.2
 
- 
setQueryTimeoutpublic void setQueryTimeout(int timeout) Set's query timeout- Since:
- 4.2
 
 
-