Reputation: 1057
I have an Oracle Stored procedure that takes CLOB input and REFCURSOR output. I invoke the SP via Spring SimpleJdbcCall passing in a RowMapper to map the results.
However, since the result set is large, I need to provide callback feature to the client. I can't quite figure out how to add callback for an SP call using Spring - both with and without SimpleJdbcCall.
One thought I have is to pass-in a RowCallbackHandler. Will this work or is there a better way to solve this problem? Any help here is appreciated.
private Map<String, Object> arguments = ...;
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(this.jdbcTemplate)
.withCatalogName(this.packageName)
.withProcedureName(this.storedProcName)
.withoutProcedureColumnMetaDataAccess()
.declareParameters(this.outputParameters.toArray(new SqlOutParameter[]{}));
if(!isEmpty(inputParameters)) {
jdbcCall.declareParameters(inputParameters.toArray(new SqlParameter[]{}));
}
this.outputParameters.add(new SqlOutParameter(outputParamName, VARCHAR, rowMapper));
jdbcCall.execute(arguments);
Upvotes: 1
Views: 5990
Reputation: 121202
Actually the RowCallbackHandler
is a good solution for your case:
this.outputParameters.add(new SqlOutParameter(outputParamName, VARCHAR, new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
// Build model object from ROW and invoke client service from here
}
}));
jdbcCall.execute(arguments);
Upvotes: 2