MyBatis中对List<Object> 对象List的批处理插入操作

<insert id="insertAddressPosition" parameterType="java.util.List">
        <selectKey keyProperty="p1" order="BEFORE" resultType="int">
            select seq_app_addresslist.nextval from dual
        </selectKey>
        insert into appuser.ADDRESS_POSITION_BACKUP
        (row_id,pos_id,pos_name,create_date,update_date)
        <foreach collection="list" item="pop" separator="union all"
            open="(" close=")">
            select
            #{p1},#{pop.ROLE_ID,jdbcType=VARCHAR},#{pop.ROLE_NAME,jdbcType=VARCHAR},
            sysdate,sysdate
            from dual
        </foreach>
    </insert>

参照此篇文章 http://ask.csdn.net/questions/155651
这篇文章也不错 http://blog.csdn.net/moneyshi/article/details/22807239

<insert id="insertAddressPosition" parameterType="java.util.List">
        <selectKey keyProperty="p1" order="BEFORE" resultType="int">
            select seq_app_addresslist.nextval from dual
        </selectKey>
        insert into appuser.ADDRESS_POSITION_BACKUP
        (row_id,pos_id,pos_name,create_date,update_date)
        <foreach collection="list" item="pop" separator="union all"
            open="(" close=")">
            select
            #{p1},#{pop.ROLE_ID,jdbcType=VARCHAR},#{pop.ROLE_NAME,jdbcType=VARCHAR},
            sysdate,sysdate
            from dual
        </foreach>
    </insert>

猜你喜欢

转载自blog.csdn.net/u011277123/article/details/78480322
今日推荐