- 通过foreach动态拼装sql
<insert id="insert" parameterType="com.zxl.entity.ZxlUser">
insert into ZXL_USER (id, user_name)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=BIGINT}, #{item.userName,jdbcType=VARCHAR})
</foreach>
</insert>
- batch类型的excutor
@Autowired
private SqlSessionFactory sqlSessionFactory;
public void a() {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
sqlSession.getMapper(ZxlUserMapper.class);
// 调用dao
sqlSession.commit();
sqlSession.clearCache();
}