【轉】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>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章