• MyBatis Oracle 批量新增、更新和删除


    1.批量新增

    <insert id="addRcalModelProperty" parameterType="java.util.List" useGeneratedKeys="false">
            INSERT INTO T_RCSL_MODEL_PROPERTY (
              ID,
              MODEL_ID,
              PROPERTY_CODE,
              PROPERTY_DETAIL_CODE,
              CREATE_TIME,
              UPDATE_TIME
            )
            <foreach collection="list" item="item" index="index" separator="union all">
                (SELECT
                #{item.id},
                #{item.modelId},
                #{item.propertyCode},
                #{item.propertyDetailCode},
                #{item.createTime},
                #{item.updateTime}
                FROM
                dual)
            </foreach>
        </insert>

    2.批量更新

    <update id="updateRcalModelProperty" parameterType="java.util.List">
            begin
            <foreach collection="list" item="item" index="index" separator=";" >
                update T_RCSL_MODEL_PROPERTY
                <set>
                    <if test="item.id != null and item.id != ''">
                        id = #{item.id},
                    </if>
                    <if test="item.modelId != null and item.modelId != ''">
                        HEAD = #{item.modelId},
                    </if>
                </set>
                where id = #{item.id}
            </foreach>
            ;end;
    </update>

    3.批量删除

    <delete id="deleteRcalModelProperty" parameterType="java.util.List">
            delete from T_RCSL_MODEL_PROPERTY
            <where>
                <foreach collection="list" index="index" item="item" open="(" separator="or" close=")">
                    id = #{item.id}
                </foreach>
            </where>
    </delete>
  • 相关阅读:
    MyBatis代码自动生成
    英语单词--程序员专属
    动态规划小例子
    Dijkstra 算法
    矩阵变换
    (转)贝塞尔曲线
    山寨了@上位者的怜悯的样式= =
    HDU 1115 (计算多边形重心)
    HDU 1147(线段相交+链表)
    HDU 1276 (直接链表模拟)
  • 原文地址:https://www.cnblogs.com/MurasakiSeiFu/p/7991312.html
Copyright © 2020-2023  润新知