Use StoredProcedure to call sp, if not set the rowmapper for out parameter which type is cursor, will throw null pointer exception [SPR-11076] #15702
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Gang opened SPR-11076 and commented
Class:org.springframework.jdbc.core.JdbcTemplate
method:extractOutputParameters
this code:
Object out = cs.getObject(sqlColIndex);
if (out instanceof ResultSet) {
if (outParam.isResultSetSupported()) {
returnedResults.putAll(processResultSet((ResultSet) out, outParam));
}
else {
String rsName = outParam.getName();
SqlReturnResultSet rsParam = new SqlReturnResultSet(rsName, new ColumnMapRowMapper());
returnedResults.putAll(processResultSet(cs.getResultSet(), rsParam));
logger.info("Added default SqlReturnResultSet parameter named " + rsName);
}
when i use it like this in java code:
declareParameter(new SqlOutParameter("active_rs", OracleTypes.CURSOR));
not define the mapper for a out cursor param, it will call this code
returnedResults.putAll(processResultSet(cs.getResultSet(), rsParam));
but cs.getResultSet() return null object, so when process the result, will throw null pointer exeception.
in this situation it use this code to process the result, it's fine.
returnedResults.putAll(processResultSet((ResultSet) out, outParam));
so we need change the "cs.getResultSet()" to "(ResultSet) out" to process the result.
thanks!
Affects: 3.2.3
Referenced from: commits 3ff3805, 6fb1098
Backported to: 3.2.6
The text was updated successfully, but these errors were encountered: