You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SqlParameterSource needs method for extracting parameter names [SPR-16361] #20908
NamedParameterJdbcOperations supports passing in custom implementations of SqlParameterSource. Unfortunately doing so silently breaks. The issue is that SqlParameterSource offers no way of accessing the names of the parameters so SqlParameterSourceUtils#extractCaseInsensitiveParameterNames has to cast to the implementation classes BeanPropertySqlParameterSource and MapSqlParameterSource. For any other implementation class an empty map is returned.
I suppose you're using SimpleJdbcInsert and friends there? Parameter name extraction isn't needed for regular NamedParameterJdbcTemplate usage but is indeed used for matching purposes in insert and call operation objects.
I've introduced a getParameterNames() method on SqlParameterSource, with a default implementation that returns null for not determinable. Being at it, I've also added default implementations of getSqlType and getTypeName.
How is SqlParameterSourceUtils#extractCaseInsensitiveParameterNames being reached there? It only seems to be called from Table/CallMetaDataContext which is only being used by AbstractJdbcInsert/Call.
I confused two things. We have a custom NamedParameterJdbcTemplate subclass that uses Oracle extensions (OraclePreparedStatement#setObjectAtName) to directly bind parameters by name without having to parse and rewrite the query.
We could contribute the implementation if that is of interest, it would need some cleanup (eg. we compile against Oracle classes which would be a no-go for Spring).
Activity
spring-projects-issues commentedon Jan 9, 2018
Juergen Hoeller commented
I suppose you're using
SimpleJdbcInsertand friends there? Parameter name extraction isn't needed for regularNamedParameterJdbcTemplateusage but is indeed used for matching purposes in insert and call operation objects.spring-projects-issues commentedon Jan 9, 2018
Juergen Hoeller commented
I've introduced a
getParameterNames()method onSqlParameterSource, with a default implementation that returnsnullfor not determinable. Being at it, I've also added default implementations ofgetSqlTypeandgetTypeName.spring-projects-issues commentedon Jan 9, 2018
Philippe Marschall commented
Thanks for the quick response. Actually we were using
NamedParameterJdbcTemplate#query(String, SqlParameterSource, RowCallbackHandler)spring-projects-issues commentedon Jan 9, 2018
Juergen Hoeller commented
How is
SqlParameterSourceUtils#extractCaseInsensitiveParameterNamesbeing reached there? It only seems to be called fromTable/CallMetaDataContextwhich is only being used byAbstractJdbcInsert/Call.spring-projects-issues commentedon Jan 9, 2018
Philippe Marschall commented
I confused two things. We have a custom
NamedParameterJdbcTemplatesubclass that uses Oracle extensions (OraclePreparedStatement#setObjectAtName) to directly bind parameters by name without having to parse and rewrite the query.We could contribute the implementation if that is of interest, it would need some cleanup (eg. we compile against Oracle classes which would be a no-go for Spring).
spring-projects-issues commentedon Jan 9, 2018
Juergen Hoeller commented
Alright, my implementation here should be good to go then.
As for the Oracle extension, you could consider submitting it to the Spring Data JDBC Extensions project which has plenty of Oracle extensions already (built against the Oracle JDBC driver API): https://github.com/spring-projects/spring-data-jdbc-ext/tree/master/spring-data-oracle
spring-projects-issues commentedon Jan 9, 2018
Philippe Marschall commented
Thank you, I wasn't aware of this.