Решение, на которое ссылается sinha, не сработало для меня.Я смог решить эту проблему, используя JdbcTemplate#call(CallableStatementCreator, List<SqlParameter>)
.Например:
private static final String sql = "{call schema_name.the_stored_procedure(?, ?, ?)}";
// The input parameters of the stored procedure
private static final List<SqlParameter> declaredParams = Arrays.asList(
new SqlParameter("nameOfFirstInputParam", Types.VARCHAR),
new SqlParameter("nameOfSecondInputParam", Types.VARCHAR),
new SqlParameter("nameOfThirdInputParam", Types.VARCHAR));
private static final CallableStatementCreatorFactory cscFactory
= new CallableStatementCreatorFactory(sql, declaredParams);
// The result sets of the stored procedure
private static final List<SqlParameter> returnedParams = Arrays.<SqlParameter>asList(
new SqlReturnResultSet("nameOfFirstResultSet", SomeRowMapper.INSTANCE),
new SqlReturnResultSet("nameOfSecondResultSet", SomeOtherRowMapper.INSTANCE));
public static Map<String, Object> call(JdbcTemplate jdbcTemplate,
String param0,
String param1,
String param2) {
final Map<String, Object> actualParams = new HashMap<>();
actualParams.put("nameOfFirstInputParam", param0);
actualParams.put("nameOfSecondInputParam", param1);
actualParams.put("nameOfThirdInputParam", param2);
CallableStatementCreator csc = cscFactory.newCallableStatementCreator(actualParams);
Map<String, Object> results = jdbcTemplate.call(csc, returnedParams);
// The returned map will including a mapping for each result set.
//
// {
// "nameOfFirstResultSet" -> List<SomeObject>
// "nameOfSecondResultSet" -> List<SomeOtherObject>
// }
//
// For this example, we just return the heterogeneous map. In practice,
// it's better to return an object with more type information. In other
// words, don't make client code cast the result set lists. Encapsulate
// that casting within this method.
return results;
}