批量新增
public void addMainTainConfig(List<MainTainConfig> list){
final List<MainTainConfig> tempBpplist = list;
String sql="insert into t_maintain_config(user_id, xxx_id, xxx_id, type)" +
" values(?,?,?,?)";
this.getJdbcTemplate().batchUpdate(sql,new BatchPreparedStatementSetter() {
@Override
public int getBatchSize() {
return tempBpplist.size();
}
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
ps.setString(1, tempBpplist.get(i).getUser_id());
ps.setInt(2, tempBpplist.get(i).getxxx_id());
ps.setInt(3, tempBpplist.get(i).getxxx_id());
ps.setString(4, tempBpplist.get(i).getType());
}
});
}
批量删除
public void deleteMainTainConfig(List<MainTainConfig> list){
final List<MainTainConfig> tempBpplist = list;
String sql="delete from t_maintain_config where user_id = ? ";
this.getJdbcTemplate().batchUpdate(sql,new BatchPreparedStatementSetter() {
@Override
public int getBatchSize() {
return tempBpplist.size();
}
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
ps.setString(1, tempBpplist.get(i).getUser_id());
}
});
}