Top Description Methods
jakarta.persistence

public Interface StoredProcedureQuery

extends Query
Imports
java.util.Calendar, .Date, .List

Interface used to control stored procedure query execution.

Stored procedure query execution may be controlled in accordance with the following:

Since
2.1
See Also
Query, Parameter

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if first result corresponds to result set
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.

public int

Returns:

the update count or -1 if there is no pending result or if the next result is not an update count.
executeUpdate
()

Redeclares jakarta.persistence.Query.executeUpdate.

Return the update count of -1 if there is no pending result or if the first result is not an update count.

public Object

Returns:

the result that is passed back through the parameter
getOutputParameterValue
(int
parameter position
position
)

Retrieve a value passed back from the procedure through an INOUT or OUT parameter.

public Object

Returns:

the result that is passed back through the parameter
getOutputParameterValue
(String
name of the parameter as registered or specified in metadata
parameterName
)

Retrieve a value passed back from the procedure through an INOUT or OUT parameter.

public List<E>

Returns:

a list of the results or null is the next item is not a result set
getResultList
()

Redeclares jakarta.persistence.Query.getResultList.

Retrieve the list of results from the next result set.

public Object

Returns:

the result or null if the next item is not a result set
getSingleResult
()

Redeclares jakarta.persistence.Query.getSingleResult.

Retrieve a single result from the next result set.

public Object

Returns:

the result or null if the next item is not a result set or if there is no result in the next result set
getSingleResultOrNull
()

Redeclares jakarta.persistence.Query.getSingleResultOrNull.

Retrieve a single result from the next result set.

public int

Returns:

update count or -1 if there is no pending result or if the next result is not an update count
getUpdateCount
()

Return the update count or -1 if there is no pending result or if the next result is not an update count.

public boolean

Returns:

true if next result corresponds to result set
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.

public StoredProcedureQuery

Returns:

the same query instance
registerStoredProcedureParameter
(int
parameter position
position
,
Class<?>
type of the parameter
type
,
ParameterMode
parameter mode
mode
)

Register a positional parameter.

public StoredProcedureQuery

Returns:

the same query instance
registerStoredProcedureParameter
(String
name of the parameter as registered or specified in metadata
parameterName
,
Class<?>
type of the parameter
type
,
ParameterMode
parameter mode
mode
)

Register a named parameter.

public StoredProcedureQuery

Returns:

the same query instance
setCacheRetrieveMode
(CacheRetrieveMode
cache retrieval mode
cacheRetrieveMode
)

Redeclares jakarta.persistence.Query.setCacheRetrieveMode.

Set the cache retrieval mode that is in effect during query execution.

public StoredProcedureQuery

Returns:

the same query instance
setCacheStoreMode
(CacheStoreMode
cache storage mode
cacheStoreMode
)

Redeclares jakarta.persistence.Query.setCacheStoreMode.

Set the cache storage mode that is in effect during query execution.

public StoredProcedureQuery

Returns:

the same query instance
setFlushMode
(FlushModeType
flush mode
flushMode
)

Redeclares jakarta.persistence.Query.setFlushMode.

Set the flush mode type to be used for the query execution.

public StoredProcedureQuery

Returns:

the same query instance
setHint
(String
name of the property or hint
hintName
,
Object
value for the property or hint
value
)

Redeclares jakarta.persistence.Query.setHint.

Set a query property or hint.

public <T> StoredProcedureQuery

Returns:

the same query instance
setParameter
(Parameter<T>
parameter object
param
,
T
parameter value
value
)

Redeclares jakarta.persistence.Query.setParameter.

Bind the value of a Parameter object.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(Parameter<Calendar>
parameter object
param
,
Calendar
parameter value
value
,
TemporalType
temporal type
temporalType
)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Calendar to a Parameter object.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(Parameter<Date>
parameter object
param
,
Date
parameter value
value
,
TemporalType
temporal type
temporalType
)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Date to a Parameter object.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(String
parameter name
name
,
Object
parameter value
value
)

Redeclares jakarta.persistence.Query.setParameter.

Bind an argument value to a named parameter.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(String
parameter name
name
,
Calendar
parameter value
value
,
TemporalType
temporal type
temporalType
)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Calendar to a named parameter.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(String
parameter name
name
,
Date
parameter value
value
,
TemporalType
temporal type
temporalType
)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Date to a named parameter.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(int
position
position
,
Object
parameter value
value
)

Redeclares jakarta.persistence.Query.setParameter.

Bind an argument value to a positional parameter.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(int
position
position
,
Calendar
parameter value
value
,
TemporalType
temporal type
temporalType
)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Calendar to a positional parameter.

public StoredProcedureQuery

Returns:

the same query instance
setParameter
(int
position
position
,
Date
parameter value
value
,
TemporalType
temporal type
temporalType
)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated since 3.2. Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Date to a positional parameter.

public StoredProcedureQuery

Returns:

the same query instance
setTimeout
(Integer
the timeout, in milliseconds, or null to indicate no timeout
timeout
)

Redeclares jakarta.persistence.Query.setTimeout.

Set the query timeout, in milliseconds.

Inherited from jakarta.persistence.Query:
getCacheRetrieveModegetCacheStoreModegetFirstResultgetFlushModegetHintsgetLockModegetMaxResultsgetParametergetParametergetParametergetParametergetParametersgetParameterValuegetParameterValuegetParameterValuegetResultStreamgetTimeoutisBoundsetFirstResultsetLockModesetMaxResultsunwrap

Method Detail

executeback to summary
public 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.

Returns:boolean

true if first result corresponds to result set

Exceptions
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
executeUpdateback to summary
public int executeUpdate()

Redeclares jakarta.persistence.Query.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 call execute on the query if needed.

Returns:int

the update count or -1 if there is no pending result or if the next result is not an update count.

Exceptions
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
getOutputParameterValueback to summary
public Object 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:int

parameter position

Returns:Object

the result that is passed back through the parameter

Exceptions
IllegalArgumentException:
if the position does not correspond to a parameter of the query or is not an INOUT or OUT parameter
getOutputParameterValueback to summary
public Object 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:String

name of the parameter as registered or specified in metadata

Returns:Object

the result that is passed back through the parameter

Exceptions
IllegalArgumentException:
if the parameter name does not correspond to a parameter of the query or is not an INOUT or OUT parameter
getResultListback to summary
public List<E> getResultList()

Redeclares jakarta.persistence.Query.getResultList.

Retrieve the list of results from the next result set. The provider will call execute on the query if needed. A REF_CURSOR result set, if any, is retrieved in the order the REF_CURSOR parameter was registered with the query.

Returns:List<E>

a list of the results or null is the next item is not a result set

Exceptions
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
getSingleResultback to summary
public Object getSingleResult()

Redeclares jakarta.persistence.Query.getSingleResult.

Retrieve a single result from the next result set. The provider will call execute on the query if needed. A REF_CURSOR result set, if any, is retrieved in the order the REF_CURSOR parameter was registered with the query.

Returns:Object

the result or null if the next item is not a result set

Exceptions
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
getSingleResultOrNullback to summary
public Object getSingleResultOrNull()

Redeclares jakarta.persistence.Query.getSingleResultOrNull.

Retrieve a single result from the next result set. The provider will call execute on the query if needed. A REF_CURSOR result set, if any, is retrieved in the order the REF_CURSOR parameter was registered with the query.

Returns:Object

the result or null if the next item is not a result set or if there is no result in the next result set

Exceptions
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
getUpdateCountback to summary
public int getUpdateCount()

Return the update count or -1 if there is no pending result or if the next result is not an update count.

Returns:int

update count or -1 if there is no pending result or if the next result is not an update count

Exceptions
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
hasMoreResultsback to summary
public 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.

Returns:boolean

true if next result corresponds to result set

Exceptions
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
registerStoredProcedureParameterback to summary
public StoredProcedureQuery registerStoredProcedureParameter(int position, Class<?> type, ParameterMode mode)

Register a positional parameter. All parameters must be registered.

Parameters
position:int

parameter position

type:Class<?>

type of the parameter

mode:ParameterMode

parameter mode

Returns:StoredProcedureQuery

the same query instance

registerStoredProcedureParameterback to summary
public StoredProcedureQuery registerStoredProcedureParameter(String parameterName, Class<?> type, ParameterMode mode)

Register a named parameter.

Parameters
parameterName:String

name of the parameter as registered or specified in metadata

type:Class<?>

type of the parameter

mode:ParameterMode

parameter mode

Returns:StoredProcedureQuery

the same query instance

setCacheRetrieveModeback to summary
public StoredProcedureQuery setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)

Redeclares jakarta.persistence.Query.setCacheRetrieveMode.

Set the cache retrieval mode that is in effect during query execution. This cache retrieval mode overrides the cache retrieve mode in use by the entity manager.

Parameters
cacheRetrieveMode:CacheRetrieveMode

cache retrieval mode

Returns:StoredProcedureQuery

the same query instance

Since
3.2
setCacheStoreModeback to summary
public StoredProcedureQuery setCacheStoreMode(CacheStoreMode cacheStoreMode)

Redeclares jakarta.persistence.Query.setCacheStoreMode.

Set the cache storage mode that is in effect during query execution. This cache storage mode overrides the cache storage mode in use by the entity manager.

Parameters
cacheStoreMode:CacheStoreMode

cache storage mode

Returns:StoredProcedureQuery

the same query instance

Since
3.2
setFlushModeback to summary
public StoredProcedureQuery setFlushMode(FlushModeType flushMode)

Redeclares jakarta.persistence.Query.setFlushMode.

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.

Parameters
flushMode:FlushModeType

flush mode

Returns:StoredProcedureQuery

the same query instance

setHintback to summary
public StoredProcedureQuery setHint(String hintName, Object value)

Redeclares jakarta.persistence.Query.setHint.

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.

Parameters
hintName:String

name of the property or hint

value:Object

value for the property or hint

Returns:StoredProcedureQuery

the same query instance

Exceptions
IllegalArgumentException:
if the second argument is not valid for the implementation
setParameterback to summary
public <T> StoredProcedureQuery setParameter(Parameter<T> param, T value)

Redeclares jakarta.persistence.Query.setParameter.

Bind the value of a Parameter object.

Parameters
param:Parameter<T>

parameter object

value:T

parameter value

Returns:StoredProcedureQuery

the same query instance

Exceptions
IllegalArgumentException:
if the parameter does not correspond to a parameter of the query
setParameterback to summary
public StoredProcedureQuery setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated

since 3.2.

Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Calendar to a Parameter object.

Parameters
param:Parameter<Calendar>

parameter object

value:Calendar

parameter value

temporalType:TemporalType

temporal type

Returns:StoredProcedureQuery

the same query instance

Annotations
@Deprecated
since:3.2
Exceptions
IllegalArgumentException:
if the parameter does not correspond to a parameter of the query
setParameterback to summary
public StoredProcedureQuery setParameter(Parameter<Date> param, Date value, TemporalType temporalType)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated

since 3.2.

Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Date to a Parameter object.

Parameters
param:Parameter<Date>

parameter object

value:Date

parameter value

temporalType:TemporalType

temporal type

Returns:StoredProcedureQuery

the same query instance

Annotations
@Deprecated
since:3.2
Exceptions
IllegalArgumentException:
if the parameter does not correspond to a parameter of the query
setParameterback to summary
public StoredProcedureQuery setParameter(String name, Object value)

Redeclares jakarta.persistence.Query.setParameter.

Bind an argument value to a named parameter.

Parameters
name:String

parameter name

value:Object

parameter value

Returns:StoredProcedureQuery

the same query instance

Exceptions
IllegalArgumentException:
if the parameter name does not correspond to a parameter of the query or if the argument is of incorrect type
setParameterback to summary
public StoredProcedureQuery setParameter(String name, Calendar value, TemporalType temporalType)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated

since 3.2.

Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Calendar to a named parameter.

Parameters
name:String

parameter name

value:Calendar

parameter value

temporalType:TemporalType

temporal type

Returns:StoredProcedureQuery

the same query instance

Annotations
@Deprecated
since:3.2
Exceptions
IllegalArgumentException:
if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
setParameterback to summary
public StoredProcedureQuery setParameter(String name, Date value, TemporalType temporalType)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated

since 3.2.

Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Date to a named parameter.

Parameters
name:String

parameter name

value:Date

parameter value

temporalType:TemporalType

temporal type

Returns:StoredProcedureQuery

the same query instance

Annotations
@Deprecated
since:3.2
Exceptions
IllegalArgumentException:
if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
setParameterback to summary
public StoredProcedureQuery setParameter(int position, Object value)

Redeclares jakarta.persistence.Query.setParameter.

Bind an argument value to a positional parameter.

Parameters
position:int

position

value:Object

parameter value

Returns:StoredProcedureQuery

the same query instance

Exceptions
IllegalArgumentException:
if position does not correspond to a positional parameter of the query or if the argument is of incorrect type
setParameterback to summary
public StoredProcedureQuery setParameter(int position, Calendar value, TemporalType temporalType)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated

since 3.2.

Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Calendar to a positional parameter.

Parameters
position:int

position

value:Calendar

parameter value

temporalType:TemporalType

temporal type

Returns:StoredProcedureQuery

the same query instance

Annotations
@Deprecated
since:3.2
Exceptions
IllegalArgumentException:
if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
setParameterback to summary
public StoredProcedureQuery setParameter(int position, Date value, TemporalType temporalType)

Redeclares jakarta.persistence.Query.setParameter.

Deprecated

since 3.2.

Newly-written code should use the date/time types defined in java.time.

Bind an instance of java.util.Date to a positional parameter.

Parameters
position:int

position

value:Date

parameter value

temporalType:TemporalType

temporal type

Returns:StoredProcedureQuery

the same query instance

Annotations
@Deprecated
since:3.2
Exceptions
IllegalArgumentException:
if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
setTimeoutback to summary
public StoredProcedureQuery setTimeout(Integer timeout)

Redeclares jakarta.persistence.Query.setTimeout.

Set the query timeout, in milliseconds. This is a hint, and is an alternative to setting the hint jakarta.persistence.query.timeout.

Parameters
timeout:Integer

the timeout, in milliseconds, or null to indicate no timeout

Returns:StoredProcedureQuery

the same query instance

Since
3.2