for循环插入数据
Batch插入 rewriteBatchedStatements=true
MapperBatchAction<BugMapper> action = MapperBatchAction.create(BugMapper.class, sqlSessionFactory);
for (Bug bug : list) {
action.addAction(mapper->mapper.insertSelective(bug));
}
return action.doBatchActions();
Batch插入 rewriteBatchedStatements=false
MapperBatchAction<BugMapper> action = MapperBatchAction.create(BugMapper.class, sqlSessionFactory);
for (Bug bug : list) {
action.addAction(mapper->mapper.insertSelective(bug));
}
return action.doBatchActions();
Batch修改 rewriteBatchedStatements=true
public int update2000(List<Bug> list){
MapperBatchAction<BugMapper> action = MapperBatchAction.create(BugMapper.class, sqlSessionFactory);
for (Bug bug : list) {
action.addAction(mapper->mapper.updateByPrimaryKeySelective(bug));
}
return action.doBatchActions();
}
Batch修改 rewriteBatchedStatements=false
public int update2000(List<Bug> list){
MapperBatchAction<BugMapper> action = MapperBatchAction.create(BugMapper.class, sqlSessionFactory);
for (Bug bug : list) {
action.addAction(mapper->mapper.updateByPrimaryKeySelective(bug));
}
return action.doBatchActions();
}
show variables like 'general_log%' ;
set global general_log='ON' ;
# general_log_file 可查看sql最终执行的语句