MYBATIS 批量update 报错的问题
生活随笔
收集整理的這篇文章主要介紹了
MYBATIS 批量update 报错的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
update table set column='...' where id in (1,2,3)l
這樣的sql就可以了。Mybatis中這樣寫就行
<update id="batchUpdateStudentWithMap" parameterType="java.util.Map" >UPDATE STUDENT SET name = #{name} WHERE id IN<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">#{item}</foreach>
</update>
<!-- 通過logsId去doorSensorDevice表把相關id的記錄標識為0不可以 --><!-- <update id="updatedoorSensorDeviceById" parameterType="java.util.List" >UPDATE doorSensorDevice SET enable = 0WHEREid in<foreach item="logId" index="index" collection="list" open="(" separator=","
close=")"> #{logId,jdbcType=INTEGER} </foreach> </update> --> <update id="updatedoorSensorDeviceById" parameterType="java.util.Map" >UPDATE doorSensorDevice SET enable = 0 WHERE id IN<foreach collection="logIds" index="index" item="logId" open="(" separator="," close=")">#{logId}</foreach></update>
public Integer updatedoorSensorDeviceById(@Param(value="logIds")List<Integer> logIds);
?
總結
以上是生活随笔為你收集整理的MYBATIS 批量update 报错的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL 1093 You can't
- 下一篇: 服务发现与服务注册