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
Add option to check for matching number of arguments for a given PreparedStatement in ArgPreparedStatementSetter and enhance JdbcTemplate to optionally use it [SPR-5678] #10349
Currently, ArgPreparedStatementSetter.setValues simply applies the values in the args array it was created with to the given PreparedStatement. That means that if there are less arguments than placeholders, the remaining placeholders will be null. This is valid behavior in some cases, but in many cases I'd argue that this indicates a programmer error (forgetting a parameter).
It might be nice to add an option to setValues to optionally check for a matching count of arguments and placeholders. The latter can be obtained from the PreparedStatement's ParameterMetaData. The JdbcTemplate can then be updated to enable this feature so this programming error would be caught early, instead of indirectly by running the statement with accidental null values.
By disabling the option by default everything remains backwards compatible.