1.问题的发现是因为使用分页插件批量更新数据时候发现的,因为使用多线程,需要将数据分页,分区,进行批量的更新,下面贴出批量更新的部分代码:
坑1:pageHelper 不能从 pageNo = 0 开始更新,查询的
PageHelper.startPage(pageNo, pageSize); //pageNo = 0
分页拦截器 会 默认将 0 替换成 1 ,那么当 pageNo =1 的 时候 ,两次分页查询出来的数据 会有相同的;
坑2: 当查询分页的页数大于实际的分页条数,还是能够查询出来数据,会将最后一页的数据填充到查询结果中;
//线程池参数
@Bean public ExecutorService syncTradeBillExecutorService() { long keepAliveTime = 1L; int maxQueueNum = 500000;// 队列最大长度为50w // core线程和max线程数量均为11 ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(20, 20, keepAliveTime, timeUnit, new LinkedBlockingQueue(maxQueueNum)); //允许同步数据完成后,核心线程超时空闲关闭 threadPoolExecutor.allowCoreThreadTimeOut(true); return threadPoolExecutor; }
public class SyncTradeBillUtil implements Runnable { //分页大小 private