I think you are using the wrong method on JdbcTemplate . The only update method that seems to match your code snippet is
int update(String sql, Object... args)
If so, you pass params and key as a two-element vargs array, and JdbcTemplate treats key as normal binding parameters and interprets it incorrectly.
The only publicly available update method on JdbcTemplate that accepts a KeyHolder is
int update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder)
So, you need to rephrase your code to use it.
skaffman
source share