ibaits里批量update问题

qqyatou 2017-08-31 04:59:35
 <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吗?
...全文
228 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
凡迪 2017-09-07
  • 打赏
  • 举报
回复
<!-- 批量更新表数据信息 --> <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 你需要根据表字段类型自己调整下!!
bluetata 2017-09-06
  • 打赏
  • 举报
回复
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>
二月十六 2017-08-31
  • 打赏
  • 举报
回复
这个得问会ibaits……

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧