Pass correct SqlParameterSource to NamedParameterJdbcTemplate in DefaultJdbcClient

Prior to this commit, when using RowCallbackHandler or ResultSetExtractor in JdbcClient
and passing a parameter to paramSource(), an exception was thrown stating "No value
supplied for the SQL parameter 'xxxxxx'" because the SqlParameterSource used internally
was the wrong one.

Closes gh-31195
This commit is contained in:
Toshiaki Maki
2023-09-10 09:39:35 +09:00
committed by Sam Brannen
parent 436c7136e9
commit 588b5a45f8
2 changed files with 59 additions and 2 deletions

View File

@@ -205,7 +205,7 @@ final class DefaultJdbcClient implements JdbcClient {
@Override
public void query(RowCallbackHandler rch) {
if (useNamedParams()) {
namedParamOps.query(this.sql, this.namedParams, rch);
namedParamOps.query(this.sql, this.namedParamSource, rch);
}
else {
classicOps.query(getPreparedStatementCreatorForIndexedParams(), rch);
@@ -215,7 +215,7 @@ final class DefaultJdbcClient implements JdbcClient {
@Override
public <T> T query(ResultSetExtractor<T> rse) {
T result = (useNamedParams() ?
namedParamOps.query(this.sql, this.namedParams, rse) :
namedParamOps.query(this.sql, this.namedParamSource, rse) :
classicOps.query(getPreparedStatementCreatorForIndexedParams(), rse));
Assert.state(result != null, "No result from ResultSetExtractor");
return result;