public interface StoredProcedureQuery extends Query
Stored procedure query execution may be controlled in accordance with the following:
setParameter
methods are used to set the values of
all required IN
and INOUT
parameters.
It is not required to set the values of stored procedure parameters
for which default values have been defined by the stored procedure.getResultList
and getSingleResult
are
called on a StoredProcedureQuery
object, the provider
will call execute
on an unexecuted stored procedure
query before processing getResultList
or
getSingleResult
.executeUpdate
is called on a
StoredProcedureQuery
object, the provider will call
execute
on an unexecuted stored procedure query
followed by getUpdateCount
. The results of
executeUpdate
will be those of getUpdateCount
.execute
method supports both the simple case where
scalar results are passed back only via INOUT
and
OUT
parameters as well as the most general case
(multiple result sets and/or update counts, possibly also in
combination with output parameter values).execute
method returns true if the first result is a
result set, and false if it is an update count or there are no results
other than through INOUT
and OUT
parameters,
if any.execute
method returns true, the pending result set
can be obtained by calling getResultList
or
getSingleResult
.hasMoreResults
method can then be used to test
for further results.execute
or hasMoreResults
returns false,
the getUpdateCount
method can be called to obtain the
pending result if it is an update count. The getUpdateCount
method will return either the update count (zero or greater) or -1
if there is no update count (i.e., either the next result is a result set
or there is no next update count).INOUT
or OUT
parameters are extracted.getResultList
and
getUpdateCount
have been exhausted, results returned through
INOUT
and OUT
parameters can be retrieved.getOutputParameterValue
methods are used to retrieve
the values passed back from the procedure through INOUT
and OUT
parameters.REF_CURSOR
parameters for result sets the
update counts should be exhausted before calling getResultList
to retrieve the result set. Alternatively, the REF_CURSOR
result set can be retrieved through getOutputParameterValue
.
Result set mappings will be applied to results corresponding to
REF_CURSOR
parameters in the order the REF_CURSOR
parameters were registered with the query.INOUT
and OUT
parameters, execute
can be followed immediately by calls to
getOutputParameterValue
.Modifier and Type | Method and Description |
---|---|
boolean |
execute()
Return true if the first result corresponds to a result set,
and false if it is an update count or if there are no results
other than through INOUT and OUT parameters, if any.
|
int |
executeUpdate()
Return the update count of -1 if there is no pending result or
if the first result is not an update count.
|
Object |
getOutputParameterValue(int position)
Retrieve a value passed back from the procedure
through an INOUT or OUT parameter.
|
Object |
getOutputParameterValue(String parameterName)
Retrieve a value passed back from the procedure
through an INOUT or OUT parameter.
|
List |
getResultList()
Retrieve the list of results from the next result set.
|
Object |
getSingleResult()
Retrieve a single result from the next result set.
|
int |
getUpdateCount()
Return the update count or -1 if there is no pending result
or if the next result is not an update count.
|
boolean |
hasMoreResults()
Return true if the next result corresponds to a result set,
and false if it is an update count or if there are no results
other than through INOUT and OUT parameters, if any.
|
StoredProcedureQuery |
registerStoredProcedureParameter(int position,
Class type,
ParameterMode mode)
Register a positional parameter.
|
StoredProcedureQuery |
registerStoredProcedureParameter(String parameterName,
Class type,
ParameterMode mode)
Register a named parameter.
|
StoredProcedureQuery |
setFlushMode(FlushModeType flushMode)
Set the flush mode type to be used for the query execution.
|
StoredProcedureQuery |
setHint(String hintName,
Object value)
Set a query property or hint.
|
StoredProcedureQuery |
setParameter(int position,
Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a positional
parameter. |
StoredProcedureQuery |
setParameter(int position,
Date value,
TemporalType temporalType)
Bind an instance of
java.util.Date to a positional parameter. |
StoredProcedureQuery |
setParameter(int position,
Object value)
Bind an argument value to a positional parameter.
|
StoredProcedureQuery |
setParameter(Parameter<Calendar> param,
Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a Parameter object. |
StoredProcedureQuery |
setParameter(Parameter<Date> param,
Date value,
TemporalType temporalType)
Bind an instance of
java.util.Date to a Parameter object. |
<T> StoredProcedureQuery |
setParameter(Parameter<T> param,
T value)
Bind the value of a
Parameter object. |
StoredProcedureQuery |
setParameter(String name,
Calendar value,
TemporalType temporalType)
Bind an instance of
java.util.Calendar to a named parameter. |
StoredProcedureQuery |
setParameter(String name,
Date value,
TemporalType temporalType)
Bind an instance of
java.util.Date to a named parameter. |
StoredProcedureQuery |
setParameter(String name,
Object value)
Bind an argument value to a named parameter.
|
getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, getResultStream, isBound, setFirstResult, setLockMode, setMaxResults, unwrap
StoredProcedureQuery setHint(String hintName, Object value)
setHint
in interface Query
hintName
- name of the property or hintvalue
- value for the property or hintIllegalArgumentException
- if the second argument is not
valid for the implementation<T> StoredProcedureQuery setParameter(Parameter<T> param, T value)
Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valueIllegalArgumentException
- if the parameter does not
correspond to a parameter of the queryStoredProcedureQuery setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
java.util.Calendar
to a Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter does not
correspond to a parameter of the queryStoredProcedureQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
java.util.Date
to a Parameter
object.setParameter
in interface Query
param
- parameter objectvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter does not
correspond to a parameter of the queryStoredProcedureQuery setParameter(String name, Object value)
setParameter
in interface Query
name
- parameter namevalue
- parameter valueIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or if the
argument is of incorrect typeStoredProcedureQuery setParameter(String name, Calendar value, TemporalType temporalType)
java.util.Calendar
to a named parameter.setParameter
in interface Query
name
- parameter namevalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or if the
value argument is of incorrect typeStoredProcedureQuery setParameter(String name, Date value, TemporalType temporalType)
java.util.Date
to a named parameter.setParameter
in interface Query
name
- parameter namevalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or if the
value argument is of incorrect typeStoredProcedureQuery setParameter(int position, Object value)
setParameter
in interface Query
position
- positionvalue
- parameter valueIllegalArgumentException
- if position does not
correspond to a positional parameter of the query
or if the argument is of incorrect typeStoredProcedureQuery setParameter(int position, Calendar value, TemporalType temporalType)
java.util.Calendar
to a positional
parameter.setParameter
in interface Query
position
- positionvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if position does not
correspond to a positional parameter of the query or
if the value argument is of incorrect typeStoredProcedureQuery setParameter(int position, Date value, TemporalType temporalType)
java.util.Date
to a positional parameter.setParameter
in interface Query
position
- positionvalue
- parameter valuetemporalType
- temporal typeIllegalArgumentException
- if position does not
correspond to a positional parameter of the query or
if the value argument is of incorrect typeStoredProcedureQuery setFlushMode(FlushModeType flushMode)
setFlushMode
in interface Query
flushMode
- flush modeStoredProcedureQuery registerStoredProcedureParameter(int position, Class type, ParameterMode mode)
position
- parameter positiontype
- type of the parametermode
- parameter modeStoredProcedureQuery registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode)
parameterName
- name of the parameter as registered or
specified in metadatatype
- type of the parametermode
- parameter modeObject getOutputParameterValue(int position)
position
- parameter positionIllegalArgumentException
- if the position does
not correspond to a parameter of the query or is
not an INOUT or OUT parameterObject getOutputParameterValue(String parameterName)
parameterName
- name of the parameter as registered or
specified in metadataIllegalArgumentException
- if the parameter name does
not correspond to a parameter of the query or is
not an INOUT or OUT parameterboolean execute()
QueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backint executeUpdate()
execute
on the query if needed.executeUpdate
in interface Query
TransactionRequiredException
- if there is
no transaction or the persistence context has not
been joined to the transactionQueryTimeoutException
- if the statement execution
exceeds the query timeout value set and only
the statement is rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backList getResultList()
execute
on the query
if needed.
A REF_CURSOR
result set, if any, will be retrieved
in the order the REF_CURSOR
parameter was
registered with the query.getResultList
in interface Query
QueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backObject getSingleResult()
execute
on the query
if needed.
A REF_CURSOR
result set, if any, will be retrieved
in the order the REF_CURSOR
parameter was
registered with the query.getSingleResult
in interface Query
NoResultException
- if there is no result in the next
result setNonUniqueResultException
- if more than one resultQueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backboolean hasMoreResults()
QueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backint getUpdateCount()
QueryTimeoutException
- if the query execution exceeds
the query timeout value set and only the statement is
rolled backPersistenceException
- if the query execution exceeds
the query timeout value set and the transaction
is rolled backCopyright © 2018 JBoss by Red Hat. All rights reserved.