Class 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.
    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
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface jakarta.persistence.Query

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

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

        public java.lang.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​(java.lang.String name,
                                                                 java.lang.Class<T> type)
        Specified by:
        getParameter in interface jakarta.persistence.Query
      • getParameter

        public <T> jakarta.persistence.Parameter<T> getParameter​(int position,
                                                                 java.lang.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​(java.lang.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<java.util.Calendar> param,
                                                                     java.util.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<java.util.Date> param,
                                                                     java.util.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,
                                                                                         java.lang.Class type,
                                                                                         jakarta.persistence.ParameterMode mode)
        Specified by:
        registerStoredProcedureParameter in interface jakarta.persistence.StoredProcedureQuery
      • registerStoredProcedureParameter

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

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

        public java.lang.Object getOutputParameterValue​(java.lang.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 java.util.Map<java.lang.String,​java.lang.Object> getHints()
        Specified by:
        getHints in interface jakarta.persistence.Query
      • getParameters

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

        public jakarta.persistence.Parameter<?> getParameter​(java.lang.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 java.lang.Object getParameterValue​(java.lang.String name)
        Specified by:
        getParameterValue in interface jakarta.persistence.Query
      • getParameterValue

        public java.lang.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​(java.lang.String hintName,
                                                                java.lang.Object value)
        Specified by:
        setHint in interface jakarta.persistence.Query
        Specified by:
        setHint in interface jakarta.persistence.StoredProcedureQuery
      • setParameter

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

        public jakarta.persistence.StoredProcedureQuery setParameter​(java.lang.String name,
                                                                     java.util.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​(java.lang.String name,
                                                                     java.util.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,
                                                                     java.lang.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,
                                                                     java.util.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,
                                                                     java.util.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object