mybatis 批量操作

SqlSessionFactory sqlSessionFactory=getSqlSessionFactory();
//可以执行批量操作的sqlSession
SqlSession openSession=sqlSessionFactory.openSession(ExecutorType.BATCH);

try{
    Entity mapper = openSession.getMapper(Entity.class);
for (int i = 0; i < 1000; i++) {
    mapper.addEmp(new Entity());
}    
    openSession.commit();
}finally{
    openSession.close();
}

posted @ 2021-08-20 11:05  缘来是妳啊  阅读(43)  评论(0编辑  收藏  举报