JdbcTemplate queryForInt/Long is deprecated in Spring 3.2.2. What should it be replaced by?

后端 未结 6 1462
慢半拍i
慢半拍i 2021-01-30 19:36

The queryforInt/queryforLong methods in JdbcTemplate are deprecated in Spring 3.2. I can\'t find out why or what is considered the best practice to replace existing code using t

6条回答
  •  不知归路
    2021-01-30 19:38

    JdbcTemplate#queryForInt returns 0 if the column value is SQL NULL or 0. There is no way to distinguish one case from the other. I think this is the main reason why the method is deprecated. BTW, ResultSet#getInt behaves similarly. Though, we can distinguish between these two cases by ResultSet#wasNull.

提交回复
热议问题