Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spring-projects-issues opened this issue Nov 7, 2013 · 0 comments
Assignees
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

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues spring-projects-issues added type: bug A general bug in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0 GA milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants