We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Transactional(rollbackFor = Exception.class) @Override public boolean saveBatch(Collection<T> entityList, int batchSize) { String sqlStatement = getSqlStatement(SqlMethod.INSERT_ONE); return executeBatch(entityList, batchSize, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity)); } public static <E> boolean executeBatch(Class<?> entityClass, Log log, Collection<E> list, int batchSize, BiConsumer<SqlSession, E> consumer) { Assert.isFalse(batchSize < 1, "batchSize must not be less than one"); return !CollectionUtils.isEmpty(list) && executeBatch(entityClass, log, sqlSession -> { int size = list.size(); int idxLimit = Math.min(batchSize, size); int i = 1; for (E element : list) { consumer.accept(sqlSession, element); if (i == idxLimit) { sqlSession.flushStatements(); idxLimit = Math.min(idxLimit + batchSize, size); } i++; } }); }
粗浅的理解 批量插入 还是循环调用 sqlSession的 insert 当批量数目达到阈值 进行flush , 如果有理解不到位的,还请给解释下
mybatis-plus 3.5.8 spring boot starter
The text was updated successfully, but these errors were encountered:
按照这个理解,粗浅的理解是实现了 伪批量插入 并未实现真实的批量插入
Sorry, something went wrong.
No branches or pull requests
确认
功能改进
粗浅的理解 批量插入 还是循环调用 sqlSession的 insert 当批量数目达到阈值 进行flush , 如果有理解不到位的,还请给解释下
参考资料
mybatis-plus 3.5.8 spring boot starter
The text was updated successfully, but these errors were encountered: