Package jakarta.persistence
Interface StoredProcedureQuery
- 
- All Superinterfaces:
- Query
 
 public interface StoredProcedureQuery extends Query Interface used to control stored procedure query execution.Stored procedure query execution may be controlled in accordance with the following: - The setParametermethods are used to set the values of all requiredINandINOUTparameters. It is not required to set the values of stored procedure parameters for which default values have been defined by the stored procedure.
- 
 When getResultListandgetSingleResultare called on aStoredProcedureQueryobject, the provider will callexecuteon an unexecuted stored procedure query before processinggetResultListorgetSingleResult.
- 
 When executeUpdateis called on aStoredProcedureQueryobject, the provider will callexecuteon an unexecuted stored procedure query followed bygetUpdateCount. The results ofexecuteUpdatewill be those ofgetUpdateCount.
- 
 The executemethod supports both the simple case where scalar results are passed back only viaINOUTandOUTparameters as well as the most general case (multiple result sets and/or update counts, possibly also in combination with output parameter values).
- 
 The executemethod 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 throughINOUTandOUTparameters, if any.
- 
 If the executemethod returns true, the pending result set can be obtained by callinggetResultListorgetSingleResult.
- 
 The hasMoreResultsmethod can then be used to test for further results.
- 
 If executeorhasMoreResultsreturns false, thegetUpdateCountmethod can be called to obtain the pending result if it is an update count. ThegetUpdateCountmethod 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).
- 
 For portability, results that correspond to JDBC result sets and 
 update counts need to be processed before the values of any 
 INOUTorOUTparameters are extracted.
- 
 After results returned through getResultListandgetUpdateCounthave been exhausted, results returned throughINOUTandOUTparameters can be retrieved.
- 
 The getOutputParameterValuemethods are used to retrieve the values passed back from the procedure throughINOUTandOUTparameters.
- 
 When using REF_CURSORparameters for result sets the update counts should be exhausted before callinggetResultListto retrieve the result set. Alternatively, theREF_CURSORresult set can be retrieved throughgetOutputParameterValue. Result set mappings will be applied to results corresponding toREF_CURSORparameters in the order theREF_CURSORparameters were registered with the query.
- 
 In the simplest case, where results are returned only via 
 INOUTandOUTparameters,executecan be followed immediately by calls togetOutputParameterValue.
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanexecute()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.intexecuteUpdate()Return the update count of -1 if there is no pending result or if the first result is not an update count.ObjectgetOutputParameterValue(int position)Retrieve a value passed back from the procedure through an INOUT or OUT parameter.ObjectgetOutputParameterValue(String parameterName)Retrieve a value passed back from the procedure through an INOUT or OUT parameter.ListgetResultList()Retrieve the list of results from the next result set.ObjectgetSingleResult()Retrieve a single result from the next result set.intgetUpdateCount()Return the update count or -1 if there is no pending result or if the next result is not an update count.booleanhasMoreResults()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.StoredProcedureQueryregisterStoredProcedureParameter(int position, Class type, ParameterMode mode)Register a positional parameter.StoredProcedureQueryregisterStoredProcedureParameter(String parameterName, Class type, ParameterMode mode)Register a named parameter.StoredProcedureQuerysetFlushMode(FlushModeType flushMode)Set the flush mode type to be used for the query execution.StoredProcedureQuerysetHint(String hintName, Object value)Set a query property or hint.StoredProcedureQuerysetParameter(int position, Object value)Bind an argument value to a positional parameter.StoredProcedureQuerysetParameter(int position, Calendar value, TemporalType temporalType)Bind an instance ofjava.util.Calendarto a positional parameter.StoredProcedureQuerysetParameter(int position, Date value, TemporalType temporalType)Bind an instance ofjava.util.Dateto a positional parameter.StoredProcedureQuerysetParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)Bind an instance ofjava.util.Calendarto aParameterobject.StoredProcedureQuerysetParameter(Parameter<Date> param, Date value, TemporalType temporalType)Bind an instance ofjava.util.Dateto aParameterobject.<T> StoredProcedureQuerysetParameter(Parameter<T> param, T value)Bind the value of aParameterobject.StoredProcedureQuerysetParameter(String name, Object value)Bind an argument value to a named parameter.StoredProcedureQuerysetParameter(String name, Calendar value, TemporalType temporalType)Bind an instance ofjava.util.Calendarto a named parameter.StoredProcedureQuerysetParameter(String name, Date value, TemporalType temporalType)Bind an instance ofjava.util.Dateto a named parameter.- 
Methods inherited from interface jakarta.persistence.QuerygetFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, getResultStream, isBound, setFirstResult, setLockMode, setMaxResults, unwrap
 
- 
 
- 
- 
- 
Method Detail- 
setHintStoredProcedureQuery setHint(String hintName, Object value) Set a query property or hint. The hints elements may be used to specify query properties and hints. Properties defined by this specification must be observed by the provider. Vendor-specific hints that are not recognized by a provider must be silently ignored. Portable applications should not rely on the standard timeout hint. Depending on the database in use, this hint may or may not be observed.- Specified by:
- setHintin interface- Query
- Parameters:
- hintName- name of the property or hint
- value- value for the property or hint
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the second argument is not valid for the implementation
 
 - 
setParameter<T> StoredProcedureQuery setParameter(Parameter<T> param, T value) Bind the value of aParameterobject.- Specified by:
- setParameterin interface- Query
- Parameters:
- param- parameter object
- value- parameter value
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter does not correspond to a parameter of the query
 
 - 
setParameterStoredProcedureQuery setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) Bind an instance ofjava.util.Calendarto aParameterobject.- Specified by:
- setParameterin interface- Query
- Parameters:
- param- parameter object
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter does not correspond to a parameter of the query
 
 - 
setParameterStoredProcedureQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType) Bind an instance ofjava.util.Dateto aParameterobject.- Specified by:
- setParameterin interface- Query
- Parameters:
- param- parameter object
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter does not correspond to a parameter of the query
 
 - 
setParameterStoredProcedureQuery setParameter(String name, Object value) Bind an argument value to a named parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- name- parameter name
- value- parameter value
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or if the argument is of incorrect type
 
 - 
setParameterStoredProcedureQuery setParameter(String name, Calendar value, TemporalType temporalType) Bind an instance ofjava.util.Calendarto a named parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- name- parameter name
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
 
 - 
setParameterStoredProcedureQuery setParameter(String name, Date value, TemporalType temporalType) Bind an instance ofjava.util.Dateto a named parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- name- parameter name
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
 
 - 
setParameterStoredProcedureQuery setParameter(int position, Object value) Bind an argument value to a positional parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- position- position
- value- parameter value
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if position does not correspond to a positional parameter of the query or if the argument is of incorrect type
 
 - 
setParameterStoredProcedureQuery setParameter(int position, Calendar value, TemporalType temporalType) Bind an instance ofjava.util.Calendarto a positional parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- position- position
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
 
 - 
setParameterStoredProcedureQuery setParameter(int position, Date value, TemporalType temporalType) Bind an instance ofjava.util.Dateto a positional parameter.- Specified by:
- setParameterin interface- Query
- Parameters:
- position- position
- value- parameter value
- temporalType- temporal type
- Returns:
- the same query instance
- Throws:
- IllegalArgumentException- if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
 
 - 
setFlushModeStoredProcedureQuery setFlushMode(FlushModeType flushMode) Set the flush mode type to be used for the query execution. The flush mode type applies to the query regardless of the flush mode type in use for the entity manager.- Specified by:
- setFlushModein interface- Query
- Parameters:
- flushMode- flush mode
- Returns:
- the same query instance
 
 - 
registerStoredProcedureParameterStoredProcedureQuery registerStoredProcedureParameter(int position, Class type, ParameterMode mode) Register a positional parameter. All parameters must be registered.- Parameters:
- position- parameter position
- type- type of the parameter
- mode- parameter mode
- Returns:
- the same query instance
 
 - 
registerStoredProcedureParameterStoredProcedureQuery registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode) Register a named parameter.- Parameters:
- parameterName- name of the parameter as registered or specified in metadata
- type- type of the parameter
- mode- parameter mode
- Returns:
- the same query instance
 
 - 
getOutputParameterValueObject getOutputParameterValue(int position) Retrieve a value passed back from the procedure through an INOUT or OUT parameter. For portability, all results corresponding to result sets and update counts must be retrieved before the values of output parameters.- Parameters:
- position- parameter position
- Returns:
- the result that is passed back through the parameter
- Throws:
- IllegalArgumentException- if the position does not correspond to a parameter of the query or is not an INOUT or OUT parameter
 
 - 
getOutputParameterValueObject getOutputParameterValue(String parameterName) Retrieve a value passed back from the procedure through an INOUT or OUT parameter. For portability, all results corresponding to result sets and update counts must be retrieved before the values of output parameters.- Parameters:
- parameterName- name of the parameter as registered or specified in metadata
- Returns:
- the result that is passed back through the parameter
- Throws:
- IllegalArgumentException- if the parameter name does not correspond to a parameter of the query or is not an INOUT or OUT parameter
 
 - 
executeboolean 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.- Returns:
- true if first result corresponds to result set
- Throws:
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
executeUpdateint executeUpdate() Return the update count of -1 if there is no pending result or if the first result is not an update count. The provider will callexecuteon the query if needed.- Specified by:
- executeUpdatein interface- Query
- Returns:
- the update count or -1 if there is no pending result or if the next result is not an update count.
- Throws:
- TransactionRequiredException- if there is no transaction or the persistence context has not been joined to the transaction
- QueryTimeoutException- if the statement execution exceeds the query timeout value set and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
getResultListList getResultList() Retrieve the list of results from the next result set. The provider will callexecuteon the query if needed. AREF_CURSORresult set, if any, will be retrieved in the order theREF_CURSORparameter was registered with the query.- Specified by:
- getResultListin interface- Query
- Returns:
- a list of the results or null is the next item is not a result set
- Throws:
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
getSingleResultObject getSingleResult() Retrieve a single result from the next result set. The provider will callexecuteon the query if needed. AREF_CURSORresult set, if any, will be retrieved in the order theREF_CURSORparameter was registered with the query.- Specified by:
- getSingleResultin interface- Query
- Returns:
- the result or null if the next item is not a result set
- Throws:
- NoResultException- if there is no result in the next result set
- NonUniqueResultException- if more than one result
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
hasMoreResultsboolean 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.- Returns:
- true if next result corresponds to result set
- Throws:
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 - 
getUpdateCountint getUpdateCount() Return the update count or -1 if there is no pending result or if the next result is not an update count.- Returns:
- update count or -1 if there is no pending result or if the next result is not an update count
- Throws:
- QueryTimeoutException- if the query execution exceeds the query timeout value set and only the statement is rolled back
- PersistenceException- if the query execution exceeds the query timeout value set and the transaction is rolled back
 
 
- 
 
-