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 these methods.
A typical method:
int rowCount = jscoreJdbcTemplate.queryForInt(
"SELECT count(*) FROM _player WHERE nameKey = ? AND teamClub = ?",
playerNameKey.toUpperCase(),
teamNameKey.toUpperCase()
);
OK the above method needs to be re-written as follows:
Object[] params = new Object[] {
playerNameKey.toUpperCase(),
teamNameKey.toUpperCase()
};
int rowCount = jscoreJdbcTemplate.queryForObject(
"SELECT count(*) FROM _player WHERE nameKey = ? AND teamClub = ?",
params, Integer.class);
Obviously this deprecation makes the JdbcTemplate class simpler (or does it?). QueryForInt was always a convenience method (I guess) and has been around a long time. Why has it been removed. The code becomes more complicated as a result.
@Deprecated
– Shottennull
(not the case in your example). I found no other way than to duplicate now the null check code from queryForInt/Long. – Parricide