mybatis配置oracle批量插入

来源:互联网 发布:域名备案过怎么注销 编辑:程序博客网 时间:2024/05/17 03:50

方法一:

<insert id="batchInsert" parameterType="java.util.List">INSERT ALL<foreach collection="list" item="item" index="index">INTO TEST(USERNAME,PASSWORD) VALUES(#{item.userName, jdbcType=NUMERIC},#{item.password, jdbcType=VARCHAR})</foreach>SELECT 1 FROM DUAL</insert>
方法二:
<insert id="batchInsert" parameterType="java.util.List">INSERT INTO TEST(USERNAME,PASSWORD)<foreach collection="list" item="item" index="index" open="(" separator="union all" close=")">SELECT#{item.userName, jdbcType=NUMERIC},#{item.password, jdbcType=VARCHAR}FROM DUAL</foreach></insert>

原创粉丝点击