Mybatis批量修改联合主键数据的两种方法(批量修改mybatis语句)

网友投稿 456 2022-08-04


Mybatis批量修改联合主键数据的两种方法(批量修改mybatis语句)

最近遇上需要批量修改有联合主键的表数据,网上找了很多文章,最终都没找到比较合适的方法,有些只能支持少量数据批量修改,超过十几条就不行了。

最终自己摸索总结了两种方式可以批量修改数据。

第一种:

update hr_emp_org

when EMPID = #{item.empid} then #{item.isman}

when EMPID = #{item.empid} then #{item.updatetime}

when #{item.EMPID} then #{item.hrStatus}

where

EMPID in

#{item.empid}

and ORGID in

#{item.orgid}

直接结果集来两个in查询,最终可以满足。

第二种:

update hr_emp_position

when EMPID = #{item.empid} and POSITIONID = #{item.positionid} then #{item.isman}

when EMPID = #{item.empid} and POSITIONID = #{item.positionid} then #{item.createtime}

when EMPID = #{item.empid} and POSITIONID = #{item.positionid} then #{item.updatetime}

when EMPID = #{item.empid} and POSITIONID = #{item.positionid} then #{item.hrStatus}

where

EMPID in

#{item.empid}

修改条件中trim里面 case后面不填对比字段,在if里面进行对比判断。


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:vue+springboot+shiro+jwt实现登录功能(vue+springboot登录)
下一篇:springboot 整合hbase的示例代码
相关文章

 发表评论

暂时没有评论,来抢沙发吧~