Spring 3.2中不贊成使用JdbcTemplate中的queryforInt/queryforLong方法。我找不到爲什麼或被認爲是使用這些方法替換現有代碼的最佳實踐。JdbcTemplate queryForInt/Long在Spring 3.2.2中不推薦使用。它應該取代什麼?
的典型方法:
int rowCount = jscoreJdbcTemplate.queryForInt(
"SELECT count(*) FROM _player WHERE nameKey = ? AND teamClub = ?",
playerNameKey.toUpperCase(),
teamNameKey.toUpperCase()
);
確定上述方法需要重新編寫如下:(?或者它)
Object[] params = new Object[] {
playerNameKey.toUpperCase(),
teamNameKey.toUpperCase()
};
int rowCount = jscoreJdbcTemplate.queryForObject(
"SELECT count(*) FROM _player WHERE nameKey = ? AND teamClub = ?",
params, Integer.class);
這顯然不贊成讓JdbcTemplate類簡單。 QueryForInt總是一個方便的方法(我猜),並且已經存在很長時間了。爲什麼它被刪除。代碼因此變得更加複雜。
這方面的細節不贊成的方法:http://static.springsource.org/spring/docs/current/javadoc-api/deprecated-list.html – 2013-03-27 14:28:32
你說得對,我不知道爲什麼我的源沒有@ @ Deprecated' – 2013-03-27 14:30:23
將Spring版本更新到3.2.2 - 因爲它似乎在這裏首先被棄用 – 2013-03-27 14:30:46