Browse Source

之前IService.batchsize这个阈值设置为30太小了,现在默认值修改为1000,大大提升效率

Caratacus 6 years ago
parent
commit
fa955cbd90

+ 5 - 3
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/service/IService.java

@@ -51,7 +51,7 @@ public interface IService<T> {
      * @param entityList 实体对象集合
      */
     default boolean saveBatch(Collection<T> entityList) {
-        return saveBatch(entityList, 30);
+        return saveBatch(entityList, 1000);
     }
 
     /**
@@ -71,7 +71,9 @@ public interface IService<T> {
      *
      * @param entityList 实体对象集合
      */
-    boolean saveOrUpdateBatch(Collection<T> entityList);
+    default boolean saveOrUpdateBatch(Collection<T> entityList) {
+        return saveOrUpdateBatch(entityList, 1000);
+    }
 
     /**
      * <p>
@@ -146,7 +148,7 @@ public interface IService<T> {
      * @param entityList 实体对象集合
      */
     default boolean updateBatchById(Collection<T> entityList) {
-        return updateBatchById(entityList, 30);
+        return updateBatchById(entityList, 1000);
     }
 
     /**

+ 0 - 6
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/service/impl/ServiceImpl.java

@@ -164,12 +164,6 @@ public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
         return false;
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    @Override
-    public boolean saveOrUpdateBatch(Collection<T> entityList) {
-        return saveOrUpdateBatch(entityList, 30);
-    }
-
     @Transactional(rollbackFor = Exception.class)
     @Override
     public boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize) {