Class StoredProcedureQueryImpl

java.lang.Object
org.apache.openjpa.persistence.StoredProcedureQueryImpl
All Implemented Interfaces:
jakarta.persistence.Query, jakarta.persistence.StoredProcedureQuery

public class StoredProcedureQueryImpl extends Object implements jakarta.persistence.StoredProcedureQuery
Implements Store Procedure based query for JPA facade.
A stored 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 of ResultObjectProvider and Result 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 a callback 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 Details

    • StoredProcedureQueryImpl

      public StoredProcedureQueryImpl(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 Details

    • 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 interface jakarta.persistence.StoredProcedureQuery
    • getResultList

      public List getResultList()
      Specified by:
      getResultList in interface jakarta.persistence.Query
      Specified by:
      getResultList in interface jakarta.persistence.StoredProcedureQuery
    • getSingleResult

      public Object getSingleResult()
      Specified by:
      getSingleResult in interface jakarta.persistence.Query
      Specified by:
      getSingleResult in interface jakarta.persistence.StoredProcedureQuery
    • hasMoreResults

      public boolean hasMoreResults()
      Specified by:
      hasMoreResults in interface jakarta.persistence.StoredProcedureQuery
    • getUpdateCount

      public int getUpdateCount()
      Specified by:
      getUpdateCount in interface jakarta.persistence.StoredProcedureQuery
    • executeUpdate

      public int executeUpdate()
      Specified by:
      executeUpdate in interface jakarta.persistence.Query
      Specified by:
      executeUpdate in interface jakarta.persistence.StoredProcedureQuery
    • getParameter

      public <T> jakarta.persistence.Parameter<T> getParameter(String name, Class<T> type)
      Specified by:
      getParameter in interface jakarta.persistence.Query
    • getParameter

      public <T> jakarta.persistence.Parameter<T> getParameter(int position, Class<T> type)
      Specified by:
      getParameter in interface jakarta.persistence.Query
    • isBound

      public boolean isBound(jakarta.persistence.Parameter<?> param)
      Specified by:
      isBound in interface jakarta.persistence.Query
    • getParameterValue

      public <T> T getParameterValue(jakarta.persistence.Parameter<T> param)
      Specified by:
      getParameterValue in interface jakarta.persistence.Query
    • unwrap

      public <T> T unwrap(Class<T> cls)
      Specified by:
      unwrap in interface jakarta.persistence.Query
    • setParameter

      public <T> jakarta.persistence.StoredProcedureQuery setParameter(jakarta.persistence.Parameter<T> param, T value)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(jakarta.persistence.Parameter<Calendar> param, Calendar cal, jakarta.persistence.TemporalType temporalType)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(jakarta.persistence.Parameter<Date> param, Date value, jakarta.persistence.TemporalType temporalType)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • registerStoredProcedureParameter

      public jakarta.persistence.StoredProcedureQuery registerStoredProcedureParameter(int position, Class type, jakarta.persistence.ParameterMode mode)
      Specified by:
      registerStoredProcedureParameter in interface jakarta.persistence.StoredProcedureQuery
    • registerStoredProcedureParameter

      public jakarta.persistence.StoredProcedureQuery registerStoredProcedureParameter(String name, Class type, jakarta.persistence.ParameterMode mode)
      Specified by:
      registerStoredProcedureParameter in interface jakarta.persistence.StoredProcedureQuery
    • getOutputParameterValue

      public Object getOutputParameterValue(int position)
      Specified by:
      getOutputParameterValue in interface jakarta.persistence.StoredProcedureQuery
    • getOutputParameterValue

      public Object getOutputParameterValue(String parameterName)
      Specified by:
      getOutputParameterValue in interface jakarta.persistence.StoredProcedureQuery
    • setMaxResults

      public jakarta.persistence.Query setMaxResults(int maxResult)
      Specified by:
      setMaxResults in interface jakarta.persistence.Query
    • getMaxResults

      public int getMaxResults()
      Specified by:
      getMaxResults in interface jakarta.persistence.Query
    • setFirstResult

      public jakarta.persistence.Query setFirstResult(int startPosition)
      Specified by:
      setFirstResult in interface jakarta.persistence.Query
    • getFirstResult

      public int getFirstResult()
      Specified by:
      getFirstResult in interface jakarta.persistence.Query
    • getHints

      public Map<String,Object> getHints()
      Specified by:
      getHints in interface jakarta.persistence.Query
    • getParameters

      public Set<jakarta.persistence.Parameter<?>> getParameters()
      Specified by:
      getParameters in interface jakarta.persistence.Query
    • getParameter

      public jakarta.persistence.Parameter<?> getParameter(String name)
      Specified by:
      getParameter in interface jakarta.persistence.Query
    • getParameter

      public jakarta.persistence.Parameter<?> getParameter(int position)
      Specified by:
      getParameter in interface jakarta.persistence.Query
    • getParameterValue

      public Object getParameterValue(String name)
      Specified by:
      getParameterValue in interface jakarta.persistence.Query
    • getParameterValue

      public Object getParameterValue(int position)
      Specified by:
      getParameterValue in interface jakarta.persistence.Query
    • getFlushMode

      public jakarta.persistence.FlushModeType getFlushMode()
      Specified by:
      getFlushMode in interface jakarta.persistence.Query
    • setLockMode

      public jakarta.persistence.Query setLockMode(jakarta.persistence.LockModeType lockMode)
      Specified by:
      setLockMode in interface jakarta.persistence.Query
    • getLockMode

      public jakarta.persistence.LockModeType getLockMode()
      Specified by:
      getLockMode in interface jakarta.persistence.Query
    • setHint

      public jakarta.persistence.StoredProcedureQuery setHint(String hintName, Object value)
      Specified by:
      setHint in interface jakarta.persistence.Query
      Specified by:
      setHint in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(String name, Object value)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(String name, Calendar cal, jakarta.persistence.TemporalType temporalType)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(String name, Date date, jakarta.persistence.TemporalType temporalType)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(int position, Object value)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(int position, Calendar value, jakarta.persistence.TemporalType temporalType)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setParameter

      public jakarta.persistence.StoredProcedureQuery setParameter(int position, Date value, jakarta.persistence.TemporalType temporalType)
      Specified by:
      setParameter in interface jakarta.persistence.Query
      Specified by:
      setParameter in interface jakarta.persistence.StoredProcedureQuery
    • setFlushMode

      public jakarta.persistence.StoredProcedureQuery setFlushMode(jakarta.persistence.FlushModeType flushMode)
      Specified by:
      setFlushMode in interface jakarta.persistence.Query
      Specified by:
      setFlushMode in interface jakarta.persistence.StoredProcedureQuery
    • toString

      public String toString()
      Overrides:
      toString in class Object