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

CallMetaDataContext.reconcileParameters overwrites cursor name #25707

Closed
javadoug4 opened this issue Sep 4, 2020 · 2 comments
Closed

CallMetaDataContext.reconcileParameters overwrites cursor name #25707

javadoug4 opened this issue Sep 4, 2020 · 2 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: regression A bug that is also a regression
Milestone

Comments

@javadoug4
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 4, 2020
@jhoeller jhoeller self-assigned this Sep 4, 2020
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 4, 2020
@jhoeller jhoeller added this to the 5.2.9 milestone Sep 4, 2020
@jhoeller jhoeller changed the title CallMetaDataContext.reconcileParameters change in SB2 is overwriting cursor name CallMetaDataContext.reconcileParameters overwrites cursor name Sep 4, 2020
@jhoeller
Copy link
Contributor

jhoeller commented Sep 4, 2020

This seems to be an accidental regression introduced by our nullability efforts in 5.0. I'll fix this for 5.2.9, with a backport to 5.1.18 and 5.0.19 at the same time (for release on Sep 15).

@jhoeller jhoeller added the for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x label Sep 4, 2020
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.1.x Marks an issue as a candidate for backport to 5.1.x labels Sep 4, 2020
@javadoug4
Copy link
Author

Thanks for the quick response.

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: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants