mybatis中配置批量insert mysql , oracle
有时候需要传入一个list(或集合),通过mybatis进行批量Insert的,语法如下:
Mysql:
1
insert into TableName(F_ID,F_value) values
2
<foreach collection="list" item="lt" separator=",">
3
(#{lt.id},#{lt.value})
4
</foreach>
Oracle:
1
insert into TableName(F_ID,F_value)
2
<foreach collection="list" item="lt" separator="union all">
3
select #{lt.id},#{lt.value} from dual
4
</foreach>