时间:2021-07-01 10:21:17 帮助过:33人阅读
public interface UsersMapper {
public void insertEntitys(List<UserEntity> users);
}
<insert id="insertEntitys" parameterType="list" useGeneratedKeys="false">
INSERT INTO tab_user(id,name)
select cd.* from(
<foreach collection="list" item="item" index="index" close=")" open="(" separator="union">
select
#{item.id,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR}
from dual
</foreach>
) cd
</insert>
<insert id="insertEntitys" parameterType="list">
insert into tab_user(id,name) values
<foreach collection="list"item="item" index="index"separator="," >
(
#{item.id,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR}
)
</foreach>
</insert>
MyBatis之Oracle、Mysql批量插入
标签:ati union dao class collect 插入 open ora arc