mybatis批量删除

mapper接口

public void deleteUser(@Param("ids") String ids);

 

mapper.xml

  <delete id="deleteUser">
        delete from t_user where id in (${ids})
  </delete>

 

测试代码

 @Test
    public void deleteUser(){
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        mapper.deleteUser("3,4");
        sqlSession.close();
    }

 

posted @ 2023-02-28 21:15  Mr_sven  阅读(121)  评论(0编辑  收藏  举报