-
Notifications
You must be signed in to change notification settings - Fork 3
Using Caller class
Muhammad Hewedy edited this page Feb 19, 2017
·
9 revisions
spwrap
provides an alternate interface 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 the DAO
class to call the stored procedures.