jdbc加入批量插入转换参数rewriteBatchedStatements=true

取消修改基础service中没必要调用的代码
This commit is contained in:
wangxin
2018-11-14 11:32:02 +08:00
parent e37dad3b67
commit 463a43c0c1
6 changed files with 28 additions and 6 deletions

View File

@@ -109,7 +109,8 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
for(int index = 0; index < data.size();index++){
T t = data.get(index);
((CrudDao<T>) batchSqlSession.getMapper(mClass)).insert(t);
//insertForBatch不要带上ID会影响效率
((CrudDao<T>) batchSqlSession.getMapper(mClass)).insertForBatch(t);
// if(index>0&&index%batchSize==0) {
// batchSqlSession.commit();
// batchSqlSession.clearCache();