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

查询

//根据多个设备id获取设备信息
public List<Devices> getDevicesList(@Param("devicesIds") String[] devicesIds);

<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>

删除

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

更新

int updateNotifyStatusForJob(List<Long> notifyIds);
<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>
上一篇 MyBatis中插入记录后获取该条记录ID
下一篇 MyBatis mybatis-generator自定义plugin
目录
文章列表
1 CentOS下部署Magento2
CentOS下部署Magento2
2
Java多线程编程五(线程间通信之ThreadLocal)
Java多线程编程五(线程间通信之ThreadLocal)
3
设计模式(17)中介者模式
设计模式(17)中介者模式
4
Android P新特性:强制执行 FLAG_ACTIVITY_NEW_TASK 要求
Android P新特性:强制执行 FLAG_ACTIVITY_NEW_TASK 要求
5
Spring Security Oauth2 中优雅的扩展自定义(短信验证码)登录方式
Spring Security Oauth2 中优雅的扩展自定义(短信验证码)登录方式
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。