Mybatis根据List批量更新及删除记录

查询

1
2
//根据多个设备id获取设备信息
public List<Devices> getDevicesList(@Param("devicesIds") String[] devicesIds);
1
2
3
4
5
6
7
8
9
10
<select id="getDevicesList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sys_devices d
where d.devices_id in
<foreach item="devices_id" index="index" collection="devicesIds"
open="(" separator="," close=")">
#{devices_id}
</foreach>
</select>

删除

1
2
//根据主键ID批量删除记录
int deleteCategory(String[] categoryIds);
1
2
3
4
5
6
7
8
<!-- 根据主键批量删除记录 -->
<delete id="deleteCategory">
delete from category
where Category_ID in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</delete>

更新

1
int updateNotifyStatusForJob(List<Long> notifyIds);
1
2
3
4
5
6
7
8
<update id="updateNotifyStatusForJob" parameterType="java.util.List">
update notify_info
set notify_status='doing'
where notify_id IN
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :