<update id="updateKhsj" parameterClass="java.util.List">
<iterate conjunction=" ;">
update khsj set rzrs=#list[].rzrs# where bmid=#list[].bmid# and datatype=#list[].datatype# and year=#list[].year# and khtime=#list[].khtime#
</iterate>
</update>
資料庫mysql,這樣寫總是報語法錯誤,我想問的是ibaits不支持這樣批量update嗎?
uj5u.com熱心網友回復:
這個得問會ibaits……uj5u.com熱心網友回復:
mybatis比較常用的更新,不過這種資料庫IO比較大,最好批量那種更新。還有你擔心的肯定是不存在的<update id="updateBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update courseTable
<set>
userName=${item.userName}
</set>
where id = ${item.id}
</foreach>
</update>
uj5u.com熱心網友回復:
<!-- 批量更新表資料資訊 --><update id="updateKhsj" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
UPDATE khsj
<set>
rzrs=#{item.rzrs,jdbcType=VARCHAR}
</set>
WHERE bmid=#{item.bmid,jdbcType=INTEGER} and datatype=#{item.datatype,jdbcType=VARCHAR} and year=#{item.year,jdbcType=TIMESTAMP} and khtime=#{item.khtime,jdbcType=TIMESTAMP}
</foreach>
</update>
具體的jdbcType 你需要根據表欄位型別自己調整下!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/112384.html
標籤:MySQL
