当前使用版本(必填,否则不予处理)

3.1.0

该问题是如何引起的?(确定最新版也有问题再提!!!)

叠加乐观锁,没有更新到数据,但是返回为true

重现步骤(如果有就写完整)

报错信息

@Transactional(rollbackFor = Exception.class) @Override public boolean updateBatchById(Collection entityList, int batchSize) { Assert.notEmpty(entityList, "error: entityList must not be empty"); String sqlStatement = sqlStatement(SqlMethod.UPDATE_BY_ID); try (SqlSession batchSqlSession = sqlSessionBatch()) { int i = 0; for (T anEntityList : entityList) { MapperMethod.ParamMap param = new MapperMethod.ParamMap<>(); param.put(Constants.ENTITY, anEntityList); batchSqlSession.update(sqlStatement, param); if (i >= 1 && i % batchSize == 0) { batchSqlSession.flushStatements(); } i++; } batchSqlSession.flushStatements(); } return true; }

Comment From: miemieYaho

mybatis的batch操作不支持

Comment From: weiro-9-w7

mybatis的batch操作不支持

看源码貌似可以支持的

Comment From: miemieYaho

https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/executor/BatchExecutor.java

Comment From: weiro-9-w7

这个批操作是不是和BATCH操作有本质的区别哇。 https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/executor/BatchExecutor.java ==》 这个是批量更新 updateBatchById(Collection entityList, int batchSize) ==> 是ById, 有主键哇, 不是么

Comment From: miemieYaho

底层就是BatchExecutor

Comment From: dongzhaoxiang

不能给出批量更新的返回结果,那就很鸡肋了。好多重要的业务哪敢用这个批量更新