Skip to content

CallMetaDataContext.reconcileParameters overwrites cursor name #25707

Closed
@javadoug4

Description

@javadoug4

Affects: \SB2
org.springframework:spring-jdbc:5.1.9.RELEASE
Explanation. Existing code is using a named cursor.
When the Resultset comes back, it is always empty, even though when I debug through the spring-jdbc I see it getting created with correct results. The issue is with the named cursor.

Example:

this.simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate)
.withSchemaName("schema")
.withFunctionName("functionName")
.returningResultSet("myCursorName", mapperInstance);

if I name the cursor 'returnValue' then it works. Searching through the code, I saw that it is over writing 'myCursorName' with 'returnValue'. 'returnValue' seems to be the default name used internally.
In SimpleJdbcCall:

public T executeFunction(Class returnType, SqlParameterSource args) {
return (T) doExecute(args).get(getScalarOutParameterName());
}

'getScalarOutParameterName()' is returning 'returnValue' even though I named it as '.returningResultSet("myCursorName",'

But I also traced this to CallMetaDataContext.reconcileParameters around line 396:

param = declaredParams.get(getFunctionReturnName());
if (param == null && !getOutParameterNames().isEmpty()) {
param = declaredParams.get(getOutParameterNames().get(0).toLowerCase());
}
if (param == null) {
throw new InvalidDataAccessApiUsageException(
"Unable to locate declared parameter for function return value - " +
" add an SqlOutParameter with name '" + getFunctionReturnName() + "'");
}
else if (paramName != null) {
setFunctionReturnName(paramName);
}

In older version it used to have (the last 3 lines):

else {
setFunctionReturnName(param.getName());
}

paramName is 'returnValue', but it should be using what I supplied which is 'param.getName()'.
Then this would return the correct ruleset: return (T) doExecute(args).get(getScalarOutParameterName());

Please advise. Thanks.

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: backportedAn issue that has been backported to maintenance branchestype: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions