Package org.hibernate.procedure
package org.hibernate.procedure
Defines support for executing database stored procedures and functions and accessing their outputs.
This API is used as follows:
- First a reference to
ProcedureCallis obtained via one of the overloadedSharedSessionContract.createStoredProcedureCall(String)methods. - The
ProcedureCallreference is then used to "configure" the procedure call (set timeouts and such) and to perform parameter registration. All procedure parameters that the application wants to use must be registered. For each IN or INOUT parameter, a value may then be bound. - At this point we are ready to execute the procedure call and start accessing the outputs.
This is done by first calling the
ProcedureCall.getOutputs()} method. The underlying JDBC call is executed as needed. The pattern to access the returns is iteration over the outputs whileProcedureOutputs.goToNext()} returnstrueand callingProcedureOutputs.getCurrent()} during iteration:ProcedureCall call = session.createStoredProcedureCall( "some_procedure" ); ... ProcedureOutputs outputs = call.getOutputs(); while ( outputs.goToNext() ) { final Output output = outputs.getCurrent(); if ( output.isResultSet() ) { handleResultSetOutput( (ResultSetOutput) output ); } else { handleUpdateCountOutput( (UpdateCountOutput) output ); } } - Finally, output parameters can be accessed using the overloaded
ProcedureOutputs.getOutputParameterValue(ProcedureParameter)methods. For portability amongst databases, it is advised to access the output parameters after all returns have been processed.
- See Also:
-
ClassDescriptionDescribes the function return value of a
ProcedureCallexecuted via a JDBC escape of form ("{? = call ...}.Indicates either -Thrown to indicate that an attempt was made to register a stored procedure named parameter, but the underlying database reports to not support named parameters.Indicates that all outputs have been processed.Common contract for individual outputs which can be either results or update counts.Thrown to indicate a misuse of a parameterIndicates Hibernate is unable to determine the type details for a parameter.Defines support for executing database stored procedures and functions using the JDBC stored procedure SQL escape syntax.Represents the outputs of executing a JDBC statement.Models aResultSetas an Output.Models a return that is an update count (count of rows affected)