Package org.apache.openjpa.persistence
Class StoredProcedureQueryImpl
- java.lang.Object
-
- org.apache.openjpa.persistence.StoredProcedureQueryImpl
-
- All Implemented Interfaces:
jakarta.persistence.Query
,jakarta.persistence.StoredProcedureQuery
public class StoredProcedureQueryImpl extends java.lang.Object implements jakarta.persistence.StoredProcedureQuery
Implements Store Procedure based query for JPA facade.
Astored procedure query
differs from other query types because it may return more than one result set, apart from an optional update count, whereas the traditional query processing in OpenJPA via the abstractions ofResultObjectProvider
andResult
assumed that a query will return its result in a single list.
This query resorts to a callback mechanism, where the execution of the query returns not a result, but acallback object
that can be used to callback to OpenJPA kernel to get a series of results via the traditional result processing pathway.- Author:
- Pinaki Poddar, Romain Manni-Bucau
-
-
Constructor Summary
Constructors Constructor Description StoredProcedureQueryImpl(java.lang.String procedureName, MultiQueryMetaData meta, QueryImpl<?> delegate)
Construct a query for executing a Stored Procedure.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
execute()
Executes this receiver by delegation to the underlying executable query.int
executeUpdate()
OpenJPAQuery<?>
getDelegate()
Gets the facade delegate that manages bind parameters on behalf of this receiver.Query
getExecutableQuery()
Gets the kernel delegate that is handles actual execution on behalf of this receiver.int
getFirstResult()
jakarta.persistence.FlushModeType
getFlushMode()
java.util.Map<java.lang.String,java.lang.Object>
getHints()
jakarta.persistence.LockModeType
getLockMode()
int
getMaxResults()
java.lang.Object
getOutputParameterValue(int position)
java.lang.Object
getOutputParameterValue(java.lang.String parameterName)
jakarta.persistence.Parameter<?>
getParameter(int position)
<T> jakarta.persistence.Parameter<T>
getParameter(int position, java.lang.Class<T> type)
jakarta.persistence.Parameter<?>
getParameter(java.lang.String name)
<T> jakarta.persistence.Parameter<T>
getParameter(java.lang.String name, java.lang.Class<T> type)
java.util.Set<jakarta.persistence.Parameter<?>>
getParameters()
java.lang.Object
getParameterValue(int position)
<T> T
getParameterValue(jakarta.persistence.Parameter<T> param)
java.lang.Object
getParameterValue(java.lang.String name)
java.util.List
getResultList()
java.lang.Object
getSingleResult()
int
getUpdateCount()
boolean
hasMoreResults()
boolean
isBound(jakarta.persistence.Parameter<?> param)
jakarta.persistence.StoredProcedureQuery
registerStoredProcedureParameter(int position, java.lang.Class type, jakarta.persistence.ParameterMode mode)
jakarta.persistence.StoredProcedureQuery
registerStoredProcedureParameter(java.lang.String name, java.lang.Class type, jakarta.persistence.ParameterMode mode)
jakarta.persistence.Query
setFirstResult(int startPosition)
jakarta.persistence.StoredProcedureQuery
setFlushMode(jakarta.persistence.FlushModeType flushMode)
jakarta.persistence.StoredProcedureQuery
setHint(java.lang.String hintName, java.lang.Object value)
jakarta.persistence.Query
setLockMode(jakarta.persistence.LockModeType lockMode)
jakarta.persistence.Query
setMaxResults(int maxResult)
jakarta.persistence.StoredProcedureQuery
setParameter(int position, java.lang.Object value)
jakarta.persistence.StoredProcedureQuery
setParameter(int position, java.util.Calendar value, jakarta.persistence.TemporalType temporalType)
jakarta.persistence.StoredProcedureQuery
setParameter(int position, java.util.Date value, jakarta.persistence.TemporalType temporalType)
jakarta.persistence.StoredProcedureQuery
setParameter(jakarta.persistence.Parameter<java.util.Calendar> param, java.util.Calendar cal, jakarta.persistence.TemporalType temporalType)
jakarta.persistence.StoredProcedureQuery
setParameter(jakarta.persistence.Parameter<java.util.Date> param, java.util.Date value, jakarta.persistence.TemporalType temporalType)
<T> jakarta.persistence.StoredProcedureQuery
setParameter(jakarta.persistence.Parameter<T> param, T value)
jakarta.persistence.StoredProcedureQuery
setParameter(java.lang.String name, java.lang.Object value)
jakarta.persistence.StoredProcedureQuery
setParameter(java.lang.String name, java.util.Calendar cal, jakarta.persistence.TemporalType temporalType)
jakarta.persistence.StoredProcedureQuery
setParameter(java.lang.String name, java.util.Date date, jakarta.persistence.TemporalType temporalType)
java.lang.String
toString()
<T> T
unwrap(java.lang.Class<T> cls)
-
-
-
Constructor Detail
-
StoredProcedureQueryImpl
public StoredProcedureQueryImpl(java.lang.String procedureName, MultiQueryMetaData meta, QueryImpl<?> delegate)
Construct a query for executing a Stored Procedure.- Parameters:
procedureName
- name of the database stored procedure.meta
-delegate
- the delegate which manages bind parameters on behalf of this
-
-
Method Detail
-
getDelegate
public OpenJPAQuery<?> getDelegate()
Gets the facade delegate that manages bind parameters on behalf of this receiver.- Returns:
-
getExecutableQuery
public Query getExecutableQuery()
Gets the kernel delegate that is handles actual execution on behalf of this receiver.- Returns:
-
execute
public boolean execute()
Executes this receiver by delegation to the underlying executable query.
This method is multi-call safe. The underlying executable query is executed only for the first invocation. Subsequent- Specified by:
execute
in interfacejakarta.persistence.StoredProcedureQuery
-
getResultList
public java.util.List getResultList()
- Specified by:
getResultList
in interfacejakarta.persistence.Query
- Specified by:
getResultList
in interfacejakarta.persistence.StoredProcedureQuery
-
getSingleResult
public java.lang.Object getSingleResult()
- Specified by:
getSingleResult
in interfacejakarta.persistence.Query
- Specified by:
getSingleResult
in interfacejakarta.persistence.StoredProcedureQuery
-
hasMoreResults
public boolean hasMoreResults()
- Specified by:
hasMoreResults
in interfacejakarta.persistence.StoredProcedureQuery
-
getUpdateCount
public int getUpdateCount()
- Specified by:
getUpdateCount
in interfacejakarta.persistence.StoredProcedureQuery
-
executeUpdate
public int executeUpdate()
- Specified by:
executeUpdate
in interfacejakarta.persistence.Query
- Specified by:
executeUpdate
in interfacejakarta.persistence.StoredProcedureQuery
-
getParameter
public <T> jakarta.persistence.Parameter<T> getParameter(java.lang.String name, java.lang.Class<T> type)
- Specified by:
getParameter
in interfacejakarta.persistence.Query
-
getParameter
public <T> jakarta.persistence.Parameter<T> getParameter(int position, java.lang.Class<T> type)
- Specified by:
getParameter
in interfacejakarta.persistence.Query
-
isBound
public boolean isBound(jakarta.persistence.Parameter<?> param)
- Specified by:
isBound
in interfacejakarta.persistence.Query
-
getParameterValue
public <T> T getParameterValue(jakarta.persistence.Parameter<T> param)
- Specified by:
getParameterValue
in interfacejakarta.persistence.Query
-
unwrap
public <T> T unwrap(java.lang.Class<T> cls)
- Specified by:
unwrap
in interfacejakarta.persistence.Query
-
setParameter
public <T> jakarta.persistence.StoredProcedureQuery setParameter(jakarta.persistence.Parameter<T> param, T value)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(jakarta.persistence.Parameter<java.util.Calendar> param, java.util.Calendar cal, jakarta.persistence.TemporalType temporalType)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(jakarta.persistence.Parameter<java.util.Date> param, java.util.Date value, jakarta.persistence.TemporalType temporalType)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
registerStoredProcedureParameter
public jakarta.persistence.StoredProcedureQuery registerStoredProcedureParameter(int position, java.lang.Class type, jakarta.persistence.ParameterMode mode)
- Specified by:
registerStoredProcedureParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
registerStoredProcedureParameter
public jakarta.persistence.StoredProcedureQuery registerStoredProcedureParameter(java.lang.String name, java.lang.Class type, jakarta.persistence.ParameterMode mode)
- Specified by:
registerStoredProcedureParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
getOutputParameterValue
public java.lang.Object getOutputParameterValue(int position)
- Specified by:
getOutputParameterValue
in interfacejakarta.persistence.StoredProcedureQuery
-
getOutputParameterValue
public java.lang.Object getOutputParameterValue(java.lang.String parameterName)
- Specified by:
getOutputParameterValue
in interfacejakarta.persistence.StoredProcedureQuery
-
setMaxResults
public jakarta.persistence.Query setMaxResults(int maxResult)
- Specified by:
setMaxResults
in interfacejakarta.persistence.Query
-
getMaxResults
public int getMaxResults()
- Specified by:
getMaxResults
in interfacejakarta.persistence.Query
-
setFirstResult
public jakarta.persistence.Query setFirstResult(int startPosition)
- Specified by:
setFirstResult
in interfacejakarta.persistence.Query
-
getFirstResult
public int getFirstResult()
- Specified by:
getFirstResult
in interfacejakarta.persistence.Query
-
getHints
public java.util.Map<java.lang.String,java.lang.Object> getHints()
- Specified by:
getHints
in interfacejakarta.persistence.Query
-
getParameters
public java.util.Set<jakarta.persistence.Parameter<?>> getParameters()
- Specified by:
getParameters
in interfacejakarta.persistence.Query
-
getParameter
public jakarta.persistence.Parameter<?> getParameter(java.lang.String name)
- Specified by:
getParameter
in interfacejakarta.persistence.Query
-
getParameter
public jakarta.persistence.Parameter<?> getParameter(int position)
- Specified by:
getParameter
in interfacejakarta.persistence.Query
-
getParameterValue
public java.lang.Object getParameterValue(java.lang.String name)
- Specified by:
getParameterValue
in interfacejakarta.persistence.Query
-
getParameterValue
public java.lang.Object getParameterValue(int position)
- Specified by:
getParameterValue
in interfacejakarta.persistence.Query
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
- Specified by:
getFlushMode
in interfacejakarta.persistence.Query
-
setLockMode
public jakarta.persistence.Query setLockMode(jakarta.persistence.LockModeType lockMode)
- Specified by:
setLockMode
in interfacejakarta.persistence.Query
-
getLockMode
public jakarta.persistence.LockModeType getLockMode()
- Specified by:
getLockMode
in interfacejakarta.persistence.Query
-
setHint
public jakarta.persistence.StoredProcedureQuery setHint(java.lang.String hintName, java.lang.Object value)
- Specified by:
setHint
in interfacejakarta.persistence.Query
- Specified by:
setHint
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(java.lang.String name, java.lang.Object value)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(java.lang.String name, java.util.Calendar cal, jakarta.persistence.TemporalType temporalType)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(java.lang.String name, java.util.Date date, jakarta.persistence.TemporalType temporalType)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(int position, java.lang.Object value)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(int position, java.util.Calendar value, jakarta.persistence.TemporalType temporalType)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setParameter
public jakarta.persistence.StoredProcedureQuery setParameter(int position, java.util.Date value, jakarta.persistence.TemporalType temporalType)
- Specified by:
setParameter
in interfacejakarta.persistence.Query
- Specified by:
setParameter
in interfacejakarta.persistence.StoredProcedureQuery
-
setFlushMode
public jakarta.persistence.StoredProcedureQuery setFlushMode(jakarta.persistence.FlushModeType flushMode)
- Specified by:
setFlushMode
in interfacejakarta.persistence.Query
- Specified by:
setFlushMode
in interfacejakarta.persistence.StoredProcedureQuery
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-