看如下代码, 模拟我之前遇到的场景
@Test
public void updateBatchTest(){
long startTime = System.currentTimeMillis();
List<Integer> ids = Arrays.asList(1,2,3,6,7,8,9,10);
List<BatchUser> userList = userMapper.selectBatchIds(ids);
log.info("查询原始数据:{}", userList);
log.info("更新 user_name,pass_word 字段为空");
int updateCount = userMapper.updateList(ids);
log.info("更新数据条数:{}", updateCount);
for (BatchUser user : userList) {
// 更新年龄
user.setAge(9);
}
boolean updateBatch = userService.saveOrUpdateBatch(userList);
log.info("批量更新状态:{}", updateBatch);
long endTime = System.currentTimeMillis();
log.info("耗时 -> {}ms ", (endTime - startTime));
}
如果将用户名、密码字段设置为空, 再更新年龄字段值,最后只有年龄值被更新,用户名、密码为空却不能更新进库,程序正常执行完成
@Test
public voi