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.
Comment From: jhoeller
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).
Comment From: javadoug4
Thanks for the quick response.