mybatis

1、mybatis批量插入数据信息

<insert id="insertMoreEmpOrg"  parameterType="java.util.List">
    INSERT INTO
    hr_emp_org(EMPID,ORGID,ISMAN, UPDATETIME)
    VALUES
    <foreach collection="empOrgList" item="item" separator=",">
        (#{item.empid},#{item.orgid},#{item.isman},#{item.updatetime})
    </foreach>
</insert>

2、mybatis批量修改数据信息

<update id="updateMoreEmpJob" parameterType="java.util.List">
    update hr_emp_job
    <trim prefix="set" suffixOverrides=",">
        <trim prefix="INDATE =case EMPID" suffix="end,">
            <foreach collection="empJobList" item="item" index="index">
                <if test="item.indate != null">
                    when #{item.empid} then #{item.indate}
                </if>
            </foreach>
        </trim>
。。。。。
        <trim prefix="ORGID =case EMPID" suffix="end,">
            <foreach collection="empJobList" item="item" index="index">
                <if test="item.orgid != null">
                    when #{item.empid} then #{item.orgid}
                </if>
            </foreach>
        </trim>
        
    </trim>
    where
    EMPID in
    <foreach collection="empJobList" item="item" open="(" separator="," close=")">
        #{item.empid}
    </foreach>
</update>

3、mybatis批量修改数据信息(联合主键)

<update id="updateMoreEmpOrg" parameterType="java.util.List">
    update hr_emp_org
    <trim prefix="set" suffixOverrides=",">
        <trim prefix="ISMAN = CASE" suffix="end,">
            <foreach collection="empOrgList" item="item" index="index">
                <if test="item.isman != null">
                    when EMPID = #{item.empid} and ORGID = #{item.orgid} then #{item.isman}
                </if>
            </foreach>
        </trim>
        <trim prefix="UPDATETIME = CASE" suffix="end,">
            <foreach collection="empOrgList" item="item" index="index">
                <if test="item.updatetime != null">
                    when EMPID = #{item.empid} and ORGID = #{item.orgid}then #{item.updatetime}
                </if>
            </foreach>
        </trim>
    </trim>
    where
    EMPID in
    <foreach collection="empOrgList" item="item" open="(" separator="," close=")">
        #{item.empid}
    </foreach>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值