|
|||||||||
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 java.util.Map |
parameters
|
protected java.lang.Class |
resultClass
|
protected java.lang.String |
resultClassName
Deprecated. since 1.2 'resultEntityName' must be used. |
protected java.util.List |
resultDescriptors
|
protected java.lang.String |
resultEntityName
|
protected boolean |
selecting
Deprecated. since 1.2 as this information is no longer relavant to Cayenne |
Fields inherited from class org.apache.cayenne.query.AbstractQuery |
---|
name, root |
Fields inherited from interface org.apache.cayenne.query.GenericSelectQuery |
---|
CACHE_POLICY_DEFAULT, CACHE_POLICY_PROPERTY, FETCH_LIMIT_DEFAULT, FETCH_LIMIT_PROPERTY, FETCHING_DATA_ROWS_DEFAULT, FETCHING_DATA_ROWS_PROPERTY, LOCAL_CACHE, NO_CACHE, PAGE_SIZE_DEFAULT, PAGE_SIZE_PROPERTY, REFRESHING_OBJECTS_DEFAULT, REFRESHING_OBJECTS_PROPERTY, RESOLVING_INHERITED_DEFAULT, RESOLVING_INHERITED_PROPERTY, SHARED_CACHE |
Constructor Summary | |
---|---|
ProcedureQuery()
Creates an empty procedure query. |
|
ProcedureQuery(Procedure procedure)
Creates a ProcedureQuery based on a Procedure object. |
|
ProcedureQuery(Procedure procedure,
java.lang.Class resultType)
|
|
ProcedureQuery(java.lang.String procedureName)
Creates a ProcedureQuery based on a stored procedure. |
|
ProcedureQuery(java.lang.String procedureName,
java.lang.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(java.lang.String name,
java.lang.Object value)
Adds a named parameter to the internal map of parameters. |
PrefetchTreeNode |
addPrefetch(java.lang.String prefetchPath)
Adds a prefetch. |
void |
addPrefetches(java.util.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(java.util.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. |
java.lang.String |
getCachePolicy()
Returns query cache policy, which can be one of GenericSelectQuery.NO_CACHE ,
GenericSelectQuery.LOCAL_CACHE , or GenericSelectQuery.SHARED_CACHE . |
int |
getFetchLimit()
Returns the limit on the maximium number of records that can be returned by this query. |
QueryMetadata |
getMetaData(EntityResolver resolver)
Returns default select parameters. |
int |
getPageSize()
Returns query page size. |
java.util.Map |
getParameters()
Returns a map of procedure parameters. |
PrefetchTreeNode |
getPrefetchTree()
Returns a root node of prefetch tree used by this query, or null of no prefetches are configured. |
java.lang.Class |
getResultClass(java.lang.ClassLoader classLoader)
Deprecated. since 1.2 |
java.lang.String |
getResultClassName()
Deprecated. since 1.2 use getResultEntityName() |
java.util.List |
getResultDescriptors()
Returns a List of # RowDescriptor objects describing query ResultSets in
the order they are returned by the stored procedure. |
java.lang.String |
getResultEntityName()
|
void |
initWithProperties(java.util.Map properties)
Initializes query parameters using a set of properties. |
boolean |
isFetchingDataRows()
Returns true if this query should produce a list of data rows as
opposed to DataObjects, false for DataObjects. |
boolean |
isRefreshingObjects()
Returns true if the query results should replace any currently
cached values, returns false otherwise. |
boolean |
isResolvingInherited()
Returns true if objects fetched via this query should be fully resolved according to the inheritance hierarchy. |
boolean |
isSelecting()
Deprecated. since 1.2 as this information is no longer relavant to Cayenne |
void |
removeParameter(java.lang.String name)
|
void |
removePrefetch(java.lang.String prefetch)
|
void |
removeResultDescriptor(ColumnDescriptor[] descriptor)
Removes result descriptor from the list of descriptors. |
void |
setCachePolicy(java.lang.String policy)
|
void |
setFetchingDataRows(boolean flag)
|
void |
setFetchLimit(int fetchLimit)
|
void |
setPageSize(int pageSize)
|
void |
setParameters(java.util.Map parameters)
Sets a map of parameters. |
void |
setRefreshingObjects(boolean flag)
|
void |
setResolvingInherited(boolean b)
|
void |
setResultClassName(java.lang.String resultClassName)
Deprecated. since 1.2 use setResultEntityName(String) |
void |
setResultEntityName(java.lang.String resultEntityName)
|
void |
setSelecting(boolean b)
Deprecated. since 1.2 as this information is no longer relavant to Cayenne |
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, getRoot, route, setName, setRoot |
Methods inherited from interface org.apache.cayenne.query.Query |
---|
getName, getRoot, route, setName, setRoot |
Field Detail |
---|
protected java.lang.String resultClassName
protected java.lang.String resultEntityName
protected java.lang.Class resultClass
protected java.util.Map parameters
protected boolean selecting
protected java.util.List resultDescriptors
Constructor Detail |
---|
public ProcedureQuery()
public ProcedureQuery(Procedure procedure)
public ProcedureQuery(java.lang.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, java.lang.Class resultType)
public ProcedureQuery(java.lang.String procedureName, java.lang.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 java.util.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(java.util.Map properties)
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public Query createQuery(java.util.Map parameters)
createQuery
in interface ParameterizedQuery
public java.lang.String getCachePolicy()
GenericSelectQuery
GenericSelectQuery.NO_CACHE
,
GenericSelectQuery.LOCAL_CACHE
, or GenericSelectQuery.SHARED_CACHE
. NO_CACHE is generally a default
policy.
getCachePolicy
in interface GenericSelectQuery
public void setCachePolicy(java.lang.String policy)
public int getFetchLimit()
GenericSelectQuery
getFetchLimit
in interface GenericSelectQuery
public void setFetchLimit(int fetchLimit)
public int getPageSize()
GenericSelectQuery
getPageSize
in interface GenericSelectQuery
public void setPageSize(int pageSize)
public void setFetchingDataRows(boolean flag)
public boolean isFetchingDataRows()
GenericSelectQuery
true
if this query should produce a list of data rows as
opposed to DataObjects, false
for DataObjects. This is a hint to
QueryEngine executing this query.
isFetchingDataRows
in interface GenericSelectQuery
public boolean isRefreshingObjects()
GenericSelectQuery
true
if the query results should replace any currently
cached values, returns false
otherwise. If
GenericSelectQuery.isFetchingDataRows()
returns true
, this setting is not
applicable and has no effect.
isRefreshingObjects
in interface GenericSelectQuery
public void setRefreshingObjects(boolean flag)
public boolean isResolvingInherited()
GenericSelectQuery
isResolvingInherited
in interface GenericSelectQuery
public void setResolvingInherited(boolean b)
public void addParameter(java.lang.String name, java.lang.Object value)
public void removeParameter(java.lang.String name)
public java.util.Map getParameters()
public void setParameters(java.util.Map parameters)
public void clearParameters()
public java.lang.String getResultClassName()
getResultEntityName()
public java.lang.Class getResultClass(java.lang.ClassLoader classLoader)
public void setResultClassName(java.lang.String resultClassName)
setResultEntityName(String)
public boolean isSelecting()
public void setSelecting(boolean b)
public PrefetchTreeNode getPrefetchTree()
GenericSelectQuery
getPrefetchTree
in interface GenericSelectQuery
public PrefetchTreeNode addPrefetch(java.lang.String prefetchPath)
public void removePrefetch(java.lang.String prefetch)
public void addPrefetches(java.util.Collection prefetches)
public void clearPrefetches()
public java.lang.String getResultEntityName()
public void setResultEntityName(java.lang.String resultEntityName)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |