mybatis批量操作
1、sql语句里foreach循环拼接
2、foreach循环里拼接sql, 以;分割
3、利用mybatis批处理,批量提交
//添加 SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); QuartzTaskMapper mapper = sqlSession.getMapper(QuartzTaskMapper.class); try { statisticsList.forEach(statistics -> mapper.updateStatistics(statistics)); sqlSession.commit(); } catch (Exception e) { sqlSession.rollback(); e.printStackTrace(); } finally { sqlSession.close(); }