|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.query.AbstractQuery
org.apache.cayenne.query.ProcedureQuery
public class ProcedureQuery
A query based on Procedure. Can be used as a select query, or as a query of an arbitrary complexity, performing data modification, selecting data (possibly with multiple result sets per call), returning values via 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.
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)
.
Field Summary | |
---|---|
protected CapsStrategy |
columnNamesCapitalization
|
protected Map<String,Object> |
parameters
|
protected Class<?> |
resultClass
|
protected List<ColumnDescriptor[]> |
resultDescriptors
|
protected String |
resultEntityName
|
Fields inherited from class org.apache.cayenne.query.AbstractQuery |
---|
name, root |
Constructor Summary | |
---|---|
ProcedureQuery()
Creates an empty procedure query. |
|
ProcedureQuery(Procedure procedure)
Creates a ProcedureQuery based on a Procedure object. |
|
ProcedureQuery(Procedure procedure,
Class<?> resultType)
|
|
ProcedureQuery(String procedureName)
Creates a ProcedureQuery based on a stored procedure. |
|
ProcedureQuery(String procedureName,
Class<?> resultType)
|
Method Summary | |
---|---|
void |
addParameter(String name,
Object value)
Adds a named parameter to the internal map of parameters. |
PrefetchTreeNode |
addPrefetch(String prefetchPath)
Adds a prefetch. |
void |
addPrefetches(Collection<String> prefetches)
Adds all prefetches from a provided collection. |
void |
addResultDescriptor(ColumnDescriptor[] descriptor)
Adds a descriptor for a single ResultSet. |
void |
clearParameters()
Cleans up all configured parameters. |
void |
clearPrefetches()
Clears all prefetches. |
Query |
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. |
SQLAction |
createSQLAction(SQLActionVisitor visitor)
Calls "makeProcedure" on the visitor. |
void |
encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided PrintWriter. |
String[] |
getCacheGroups()
|
String |
getCachePolicy()
Deprecated. since 3.0 getCacheStrategy() replaces this method. |
QueryCacheStrategy |
getCacheStrategy()
|
CapsStrategy |
getColumnNamesCapitalization()
|
int |
getFetchLimit()
|
int |
getFetchOffset()
|
QueryMetadata |
getMetaData(EntityResolver resolver)
Returns default select parameters. |
int |
getPageSize()
|
Map<String,?> |
getParameters()
Returns a map of procedure parameters. |
PrefetchTreeNode |
getPrefetchTree()
|
List<ColumnDescriptor[]> |
getResultDescriptors()
Returns a List of descriptors for query ResultSets in the order they are returned by the stored procedure. |
String |
getResultEntityName()
|
int |
getStatementFetchSize()
|
void |
initWithProperties(Map<String,?> properties)
Initializes query parameters using a set of properties. |
boolean |
isFetchingDataRows()
|
boolean |
isRefreshingObjects()
Deprecated. since 3.0. With introduction of the cache strategies this setting is redundant, although it is still being taken into account. It will be removed in the later versions of Cayenne. |
boolean |
isResolvingInherited()
Deprecated. since 3.0. Inheritance resolving is not optional anymore. |
void |
removeParameter(String name)
|
void |
removePrefetch(String prefetch)
|
void |
removeResultDescriptor(ColumnDescriptor[] descriptor)
Removes result descriptor from the list of descriptors. |
void |
setCacheGroups(String... cacheGroups)
|
void |
setCachePolicy(String policy)
Deprecated. since 3.0 setCacheStrategy(QueryCacheStrategy) replaces this
method. |
void |
setCacheStrategy(QueryCacheStrategy strategy)
|
void |
setColumnNamesCapitalization(CapsStrategy columnNameCapitalization)
|
void |
setFetchingDataRows(boolean flag)
|
void |
setFetchLimit(int fetchLimit)
|
void |
setFetchOffset(int fetchOffset)
|
void |
setPageSize(int pageSize)
|
void |
setParameters(Map<String,?> parameters)
Sets a map of parameters. |
void |
setRefreshingObjects(boolean flag)
Deprecated. since 3.0. With introduction of the cache strategies this setting is redundant, although it is still being taken into account. It will be removed in the later versions of Cayenne. |
void |
setResolvingInherited(boolean b)
Deprecated. since 3.0. Inheritance resolving is not optional anymore. |
void |
setResultEntityName(String resultEntityName)
|
void |
setStatementFetchSize(int size)
Sets statement's fetch size (0 for no default size) |
Methods inherited from class org.apache.cayenne.query.AbstractQuery |
---|
getName, getRoot, route, setName, setRoot, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.cayenne.query.Query |
---|
getName, route |
Field Detail |
---|
protected String resultEntityName
protected Class<?> resultClass
protected CapsStrategy columnNamesCapitalization
protected Map<String,Object> parameters
protected List<ColumnDescriptor[]> resultDescriptors
Constructor Detail |
---|
public ProcedureQuery()
ProcedureQuery(String, Class)
constructor or by calling
setFetchingDataRows(boolean)
and setResultEntityName(String)
methods.
public ProcedureQuery(Procedure procedure)
ProcedureQuery(String, Class)
constructor or by calling
setFetchingDataRows(boolean)
and setResultEntityName(String)
methods.
public ProcedureQuery(String procedureName)
ProcedureQuery(String, Class)
constructor or by calling
setFetchingDataRows(boolean)
and setResultEntityName(String)
methods.
procedureName
- A name of the stored procedure. For this query to work, a
procedure with this name must be mapped in Cayenne.public ProcedureQuery(Procedure procedure, Class<?> resultType)
public ProcedureQuery(String procedureName, Class<?> resultType)
Method Detail |
---|
public QueryMetadata getMetaData(EntityResolver resolver)
AbstractQuery
getMetaData
in interface Query
getMetaData
in class AbstractQuery
public List<ColumnDescriptor[]> getResultDescriptors()
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.
public void addResultDescriptor(ColumnDescriptor[] descriptor)
public void removeResultDescriptor(ColumnDescriptor[] descriptor)
public SQLAction createSQLAction(SQLActionVisitor visitor)
createSQLAction
in interface Query
createSQLAction
in class AbstractQuery
public void initWithProperties(Map<String,?> properties)
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public Query createQuery(Map<String,?> parameters)
createQuery
in interface ParameterizedQuery
@Deprecated public String getCachePolicy()
getCacheStrategy()
replaces this method.
@Deprecated public void setCachePolicy(String policy)
setCacheStrategy(QueryCacheStrategy)
replaces this
method.
public QueryCacheStrategy getCacheStrategy()
public void setCacheStrategy(QueryCacheStrategy strategy)
public String[] getCacheGroups()
public void setCacheGroups(String... cacheGroups)
public int getFetchLimit()
public void setFetchLimit(int fetchLimit)
public int getFetchOffset()
public void setFetchOffset(int fetchOffset)
public int getPageSize()
public void setPageSize(int pageSize)
public void setFetchingDataRows(boolean flag)
public boolean isFetchingDataRows()
@Deprecated public boolean isRefreshingObjects()
@Deprecated public void setRefreshingObjects(boolean flag)
@Deprecated public boolean isResolvingInherited()
@Deprecated public void setResolvingInherited(boolean b)
public void addParameter(String name, Object value)
public void removeParameter(String name)
public Map<String,?> getParameters()
public void setParameters(Map<String,?> parameters)
public void clearParameters()
public PrefetchTreeNode getPrefetchTree()
public PrefetchTreeNode addPrefetch(String prefetchPath)
public void removePrefetch(String prefetch)
public void addPrefetches(Collection<String> prefetches)
public void clearPrefetches()
public String getResultEntityName()
public void setResultEntityName(String resultEntityName)
public CapsStrategy getColumnNamesCapitalization()
public void setColumnNamesCapitalization(CapsStrategy columnNameCapitalization)
public void setStatementFetchSize(int size)
public int getStatementFetchSize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |