我通过spring boot jdbcTemplate写了一个批量更新,响应代码是200,但是mysql recode尚未更新,我不知道原因,这是我的代码:
@Override
@Transactional
public void updateCustomCategory(List<ItemDto> itemDtoList) {
if (CollectionUtils.isNotEmpty(itemDtoList)) {
jdbcTemplate.batchUpdate("update item_tab set l1_custom_category_id = ? AND l2_custom_category_id = ? where item_id = ?",
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setLong(1, itemDtoList.get(i).getL1CustomCatId());
ps.setLong(2, itemDtoList.get(i).getL2CustomCatId());
ps.setLong(3, itemDtoList.get(i).getItemId());
}
@Override
public int getBatchSize() {
return 500;
}
});
}
}
我应该如何修改逻辑?
答案 0 :(得分:0)
此问题现已解决,添加“ rewriteBatchedStatements = true”并为“ itemid”建立索引