use of org.springframework.jdbc.core.SqlParameter in project spring-framework by spring-projects.
the class StoredProcedure method execute.
/**
* Execute the stored procedure with the provided parameter values. This is
* a convenience method where the order of the passed in parameter values
* must match the order that the parameters where declared in.
* @param inParams variable number of input parameters. Output parameters should
* not be included in this map.
* It is legal for values to be {@code null}, and this will produce the
* correct behavior using a NULL argument to the stored procedure.
* @return map of output params, keyed by name as in parameter declarations.
* Output parameters will appear here, with their values after the
* stored procedure has been called.
*/
public Map<String, Object> execute(Object... inParams) {
Map<String, Object> paramsToUse = new HashMap<>();
validateParameters(inParams);
int i = 0;
for (SqlParameter sqlParameter : getDeclaredParameters()) {
if (sqlParameter.isInputValueProvided()) {
if (i < inParams.length) {
paramsToUse.put(sqlParameter.getName(), inParams[i++]);
}
}
}
return getJdbcTemplate().call(newCallableStatementCreator(paramsToUse), getDeclaredParameters());
}
Aggregations