【转】MyBatis 通过Map更新

 

原文:mybatis使用map批量更新(Oracle)

有个需求,MyBatis 通过Map的key作为条件,value作为更新后的值来更新数据。

 

<update id="batchUpdateLogistics" parameterType="map">
    <foreach collection="callMap.entrySet()" item="value" index="key"
            open="begin" close=";end;" separator=";">
        update TD_LOGISTICS t set t.record=#{value} where t.sessionId=#{key}
    </foreach>
</update>
 
<update id="batchUpdateLogistics" parameterType="map">
    <foreach collection="callMap.entrySet()" item="value" index="key"
            open="begin" close="end;" separator="">
        update TD_LOGISTICS t set t.record=#{value} where t.sessionId=#{key};
    </foreach>
</update>
 
<update id="batchUpdateLogistics" parameterType="map">
    begin
    <foreach collection="callMap.entrySet()" item="value" index="key" separator="">
        update TD_LOGISTICS t set t.record=#{value} where t.sessionId=#{key};
    </foreach>
    end;
</update>

 

posted @ 2022-10-24 15:12  一去二三浪里小白龙  阅读(1028)  评论(0编辑  收藏  举报
//增加一段JS脚本,为目录生成使用