批量更新数据BatchPreparedStatementSetter 7行求解释
/**
* 批量更新数据
*
* @param forums
*/
public void addForums(final List<Forum> forums) {
final String sql = "INSERT INTO t_forum(forum_name,forum_desc) VALUES(?,?)";
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
public int getBatchSize() {
return forums.size();
}
public void setValues(PreparedStatement ps, int index)
throws SQLException {
Forum forum = forums.get(index);
ps.setString(1, forum.getForumName());
ps.setString(2, forum.getForumDesc());
}
});
}
[解决办法]
没有回复的帖是可以删除的