com.ibm.pdq.runtime.handlers
Interface CallHandler<T>
public interface CallHandler<T>Processes the results of an SQL stored procedure call and returns an object of type
T
that describes
the results.
Attention: It is recommended that
CallHandlerWithParameters<CAL>
be used instead
of CallHandler<T>
.
The default pureQuery behavior for annotated and inline methods executing SQL stored procedure calls is to return all
of the query results and OUT and INOUT parameters in an instance of StoredProcedureResult
.
Additionally, the default behavior is to update Map
s and pureQuery beans that were passed to the
annotated or inline method to represent OUT and INOUT parameters. For an example, see
Data.call(String, Object...)
. When some other behavior is wanted, an implementation of
CallHandlerWithParameters<CAL>
or CallHandler<T>
can be specified.
- For an inline method, an instance of an implementation of
CallHandlerWithParameters<CAL>
orCallHandler<T>
can be specified by using either the methodData.call(String, CallHandlerWithParameters, Object...)
or the methodData.call(String, CallHandler, Object...)
. - For annotated methods, implementations of
CallHandler<T>
cannot be specified. Instead,CallHandlerWithParameters<CAL>
should be used.
Specifying a CallHandler<T>
implementation causes its handleCall(CallableStatement)
method to be used to process the results of the SQL stored procedure call and to create an object of type
T
that describes the results. The created object is returned from the associated annotated or inline
method. The handleCall
method can perform other actions as well.
The object of type T
that is returned by CallHandler<T>
can contain as much
information about the results of the stored procedure call as is wanted. The following examples show possible types
for T
:
-
T
can benull
. -
T
can resembleStoredProcedureResult
and contain information such as the returned query results and the SQL stored procedure OUT and INOUT parameters. -
T
can be a completely different type of object.
Attention: pureQuery calls cstmt.execute()
before
calling handleCall(CallableStatement cstmt)
, so cstmt.execute()
must not be called
in handleCall (CallableStatement cstmt)
.
Handler.callHandlerWithParameters()
,
Data.call(String, CallHandler, Object...)
,
StoredProcedureResult
,
CallHandlerWithParameters
Method Summary
Modifier and Type | Method and Description |
---|---|
handleCall(CallableStatement cstmt)
Processes the results of an SQL stored procedure call and returns an object of type
T that describes
the results.
|
Method Detail
handleCall
T handleCall(CallableStatement cstmt) throws SQLException
cstmt
- a CallableStatement
that represents an SQL stored procedure. When this method is
called by pureQuery, cstmt
has already been executed. T
that describes the results of the SQL stored procedure call
T
that describes the results.Attention: pureQuery calls
cstmt.execute()
before callinghandleCall(CallableStatement cstmt)
, socstmt.execute()
must not be called inhandleCall (CallableStatement cstmt)
.