|
||||||||||
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 Map |
parameters
|
protected Class |
resultClass
|
protected List |
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)
Performance Note: with current EntityResolver implementation it is preferrable to use Procedure object instead of String as a query root. |
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 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 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()
|
int |
getFetchLimit()
|
QueryMetadata |
getMetaData(EntityResolver resolver)
Returns default select parameters. |
int |
getPageSize()
|
Map |
getParameters()
Returns a map of procedure parameters. |
PrefetchTreeNode |
getPrefetchTree()
|
List |
getResultDescriptors()
Returns a List of # RowDescriptor objects describing query ResultSets in
the order they are returned by the stored procedure. |
String |
getResultEntityName()
|
void |
initWithProperties(Map properties)
Initializes query parameters using a set of properties. |
boolean |
isFetchingDataRows()
|
boolean |
isRefreshingObjects()
|
boolean |
isResolvingInherited()
|
void |
removeParameter(String name)
|
void |
removePrefetch(String prefetch)
|
void |
removeResultDescriptor(ColumnDescriptor[] descriptor)
Removes result descriptor from the list of descriptors. |
void |
setCacheGroups(String[] cachGroups)
|
void |
setCachePolicy(String policy)
|
void |
setFetchingDataRows(boolean flag)
|
void |
setFetchLimit(int fetchLimit)
|
void |
setPageSize(int pageSize)
|
void |
setParameters(Map parameters)
Sets a map of parameters. |
void |
setRefreshingObjects(boolean flag)
|
void |
setResolvingInherited(boolean b)
|
void |
setResultEntityName(String resultEntityName)
|
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 Map parameters
protected List resultDescriptors
Constructor Detail |
---|
public ProcedureQuery()
public ProcedureQuery(Procedure procedure)
public ProcedureQuery(String procedureName)
Performance Note: with current EntityResolver implementation it is preferrable to use Procedure object instead of String as a query root. String root can cause unneeded EntityResolver reindexing on every call. See this mailing list thread: http://objectstyle.org/cayenne/lists/cayenne-user/2005/01/0109.html
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)
Performance Note: with current EntityResolver implementation it is preferrable to use Procedure object instead of String as a query root. String root can cause unneeded EntityResolver reindexing on every call. See this mailing list thread: http://objectstyle.org/cayenne/lists/cayenne-user/2005/01/0109.html
Method Detail |
---|
public QueryMetadata getMetaData(EntityResolver resolver)
AbstractQuery
getMetaData
in interface Query
getMetaData
in class AbstractQuery
public List getResultDescriptors()
RowDescriptor
objects describing 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.
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 properties)
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public Query createQuery(Map parameters)
createQuery
in interface ParameterizedQuery
public String getCachePolicy()
public void setCachePolicy(String policy)
public String[] getCacheGroups()
public void setCacheGroups(String[] cachGroups)
public int getFetchLimit()
public void setFetchLimit(int fetchLimit)
public int getPageSize()
public void setPageSize(int pageSize)
public void setFetchingDataRows(boolean flag)
public boolean isFetchingDataRows()
public boolean isRefreshingObjects()
public void setRefreshingObjects(boolean flag)
public boolean isResolvingInherited()
public void setResolvingInherited(boolean b)
public void addParameter(String name, Object value)
public void removeParameter(String name)
public Map getParameters()
public void setParameters(Map parameters)
public void clearParameters()
public PrefetchTreeNode getPrefetchTree()
public PrefetchTreeNode addPrefetch(String prefetchPath)
public void removePrefetch(String prefetch)
public void addPrefetches(Collection prefetches)
public void clearPrefetches()
public String getResultEntityName()
public void setResultEntityName(String resultEntityName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |