mybatis批量實現批量更新

傳進來的是一個list對象,然後根據每個對象的id來分別修改number

<update id="updateWareCommentTagBatch" parameterType="list">
  update T_WARE_COMMENT_TAG
  set NUMBER =NUMBER +
  <foreach collection="list" item="item" index="index"
           separator=" " open="case ID" close="end">
    when #{item.id} then #{item.number}
  </foreach>
  where ID in
  <foreach collection="list" separator="," open="(" close=")"  item="i" index="index" >
      #{i.id,jdbcType=INTEGER}
  </foreach>
</update>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章