Skip to content

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 the DAO class to call the stored procedures.

NOTE: OutputParamMapper is a super class of TypedOutputParamMapper is is has one method map.

NOTE: All mapping and configurations information is the same in the case of using Caller as in using DAO