-
Notifications
You must be signed in to change notification settings - Fork 3
Using Caller class
Muhammad Hewedy edited this page Mar 7, 2017
·
9 revisions
spwrap
provides an alternate interface (other than the one show in the README which using DAO
class ) to be using when calling Stored Procedure:
Example:
DataSource dataSource = ...
Caller caller = new Caller(dataSource);
Integer custId = caller.call("create_customer",
params(of("abdullah", VARCHAR), of("mohammad", VARCHAR)), // IN params
paramTypes(INTEGER), // OUT params
result -> result.getInt(1)); //the mapping function
The call method have multiple call versions:
public final void call(String procName)
public final void call(String procName, List<Param> inParams)
public final <T> List<T> call(String procName, ResultSetMapper<T> rsMapper)
public final <T> List<T> call(String procName, List<Param> inParams, ResultSetMapper<T> rsMapper)
public final <T> T call(String procName, List<ParamType> outParamsTypes, OutputParamMapper<T> paramMapper)
public final <T> T call(String procName, List<Param> inParams, List<ParamType> outParamsTypes, OutputParamMapper<T> paramMapper)
public final <T, U> Tuple<T, U> call(String procName, List<Param> inParams, List<ParamType> outParamsTypes, OutputParamMapper<U> paramMapper, ResultSetMapper<T> rsMapper)
NOTE: The
Caller
class is used by theDAO
class to call the stored procedures.
NOTE:
OutputParamMapper
is a super class ofTypedOutputParamMapper
is is has one methodmap
.
NOTE: All mapping and configurations information is the same in the case of using
Caller
as in usingDAO