场景:openSession(ExecutorType.BATCH, …)
问题:直接获取 updateByExampleSelective 返回的数量为负数
解决方式:
/// AccountingFlowMapper interface
// Ses: https://mybatis.org/mybatis-3/java-api.html
@Flush
List<BatchResult> flush();
/// Related Code
//...
accountingFlowSessionMapper.updateByExampleSelective(accountingFlow, accountingFlowExample);
// Note:BATCH 方式时,从上面直接获取影响行数会返回 -2147482646
// See:https://github.com/mybatis/mybatis-3/issues/1362#issuecomment-425169671
// See:https://groups.google.com/g/mybatis-user/c/ddRPVRzwvlc/m/l0Kg59srT6UJ
List<BatchResult> results = accountingFlowSessionMapper.flush();
// 从 BatchResult 里检查变更数量
但这里其实弄起来反而增加了复杂度,所以我最后直接不校验数量了,对数量的要求没有那么高。