Interface StoredProcedureQuery

  • All Superinterfaces:
    Query

    public interface StoredProcedureQuery
    extends Query
    Interface used to control stored procedure query execution.
    Since:
    Java Persistence 2.1
    See Also:
    Query, Parameter
    • Method Detail

      • setHint

        StoredProcedureQuery setHint​(java.lang.String hintName,
                                     java.lang.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:
        setHint in interface Query
        Parameters:
        hintName - name of the property or hint
        value - value for the property or hint
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the second argument is not valid for the implementation
      • setParameter

        <T> StoredProcedureQuery setParameter​(Parameter<T> param,
                                              T value)
        Bind the value of a Parameter object.
        Specified by:
        setParameter in interface Query
        Parameters:
        param - parameter object
        value - parameter value
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the parameter does not correspond to a parameter of the query
      • setParameter

        StoredProcedureQuery setParameter​(Parameter<java.util.Calendar> param,
                                          java.util.Calendar value,
                                          TemporalType temporalType)
        Bind an instance of java.util.Calendar to a Parameter object.
        Specified by:
        setParameter in interface Query
        Parameters:
        param - parameter object
        value - parameter value
        temporalType - temporal type
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the parameter does not correspond to a parameter of the query
      • setParameter

        StoredProcedureQuery setParameter​(Parameter<java.util.Date> param,
                                          java.util.Date value,
                                          TemporalType temporalType)
        Bind an instance of java.util.Date to a Parameter object.
        Specified by:
        setParameter in interface Query
        Parameters:
        param - parameter object
        value - parameter value
        temporalType - temporal type
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the parameter does not correspond to a parameter of the query
      • setParameter

        StoredProcedureQuery setParameter​(java.lang.String name,
                                          java.lang.Object value)
        Bind an argument to a named parameter.
        Specified by:
        setParameter in interface Query
        Parameters:
        name - parameter name
        value - parameter value
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the argument is of incorrect type
      • setParameter

        StoredProcedureQuery setParameter​(java.lang.String name,
                                          java.util.Calendar value,
                                          TemporalType temporalType)
        Bind an instance of java.util.Calendar to a named parameter.
        Specified by:
        setParameter in interface Query
        Parameters:
        name - parameter name
        value - parameter value
        temporalType - temporal type
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
      • setParameter

        StoredProcedureQuery setParameter​(java.lang.String name,
                                          java.util.Date value,
                                          TemporalType temporalType)
        Bind an instance of java.util.Date to a named parameter.
        Specified by:
        setParameter in interface Query
        Parameters:
        name - parameter name
        value - parameter value
        temporalType - temporal type
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or if the value argument is of incorrect type
      • setParameter

        StoredProcedureQuery setParameter​(int position,
                                          java.lang.Object value)
        Bind an argument to a positional parameter.
        Specified by:
        setParameter in interface Query
        Parameters:
        position - position
        value - parameter value
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the argument is of incorrect type
      • setParameter

        StoredProcedureQuery setParameter​(int position,
                                          java.util.Calendar value,
                                          TemporalType temporalType)
        Bind an instance of java.util.Calendar to a positional parameter.
        Specified by:
        setParameter in interface Query
        Parameters:
        position - position
        value - parameter value
        temporalType - temporal type
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
      • setParameter

        StoredProcedureQuery setParameter​(int position,
                                          java.util.Date value,
                                          TemporalType temporalType)
        Bind an instance of java.util.Date to a positional parameter.
        Specified by:
        setParameter in interface Query
        Parameters:
        position - position
        value - parameter value
        temporalType - temporal type
        Returns:
        the same query instance
        Throws:
        java.lang.IllegalArgumentException - if position does not correspond to a positional parameter of the query or if the value argument is of incorrect type
      • setFlushMode

        StoredProcedureQuery 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:
        setFlushMode in interface Query
        Parameters:
        flushMode - flush mode
        Returns:
        the same query instance
      • registerStoredProcedureParameter

        StoredProcedureQuery registerStoredProcedureParameter​(int position,
                                                              java.lang.Class type,
                                                              ParameterMode mode)
        Register a positional parameter. All positional parameters must be registered.
        Parameters:
        position - parameter position
        type - type of the parameter
        mode - parameter mode
        Returns:
        the same query instance
      • registerStoredProcedureParameter

        StoredProcedureQuery registerStoredProcedureParameter​(java.lang.String parameterName,
                                                              java.lang.Class type,
                                                              ParameterMode mode)
        Register a named parameter. When using parameter names, all parameters must be registered in the order in which they occur in the parameter list of the stored procedure.
        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
      • getOutputParameterValue

        java.lang.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 - parameter position
        Returns:
        the result that is passed back through the parameter
        Throws:
        java.lang.IllegalArgumentException - if the position does not correspond to a parameter of the query or is not an INOUT or OUT parameter
      • getOutputParameterValue

        java.lang.Object getOutputParameterValue​(java.lang.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:
        java.lang.IllegalArgumentException - if the parameter name does not correspond to a parameter of the query or is not an INOUT or OUT parameter
      • execute

        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:
        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
      • hasMoreResults

        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:
        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
      • getUpdateCount

        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:
        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