1、根据ID删除一个员工deleteById

  1. /**
  2. * 删除客户
  3. *
  4. * @throws SQLException
  5. */
  6. @Test
  7. public void deletedMethod() throws SQLException {
  8.  
  9. // 1.根据ID删除一个员工
  10. Integer result = employeeMapper.deleteById(1);
  11.  
  12. if (result != null || result > 0) {
  13. logger.info("++++++++++++++++删除成功+++++");
  14. }
  15.  
  16. }

2、根据多个ID删除多个员工

  1. /**
  2. * 删除客户
  3. *
  4. * @throws SQLException
  5. */
  6. @Test
  7. public void deletedMethod() throws SQLException {
  8.  
  9. // 2.多个ID删除
  10. List<Integer> idList = new ArrayList<>();
  11. idList.add(21);
  12. idList.add(20);
  13.  
  14. Integer result = employeeMapper.deleteBatchIds(idList);
  15.  
  16. if (result != null || result > 0) {
  17. logger.info("++++++++++++++++删除成功+++++");
  18. }
  19.  
  20. }

3、根据map条件删除

  1. /**
  2. * 删除客户
  3. *
  4. * @throws SQLException
  5. */
  6. @Test
  7. public void deletedMethod() throws SQLException {
  8.  
  9. // 3.根据map条件删除
  10. Employee employee = employeeMapper.selectById(19);
  11.  
  12. Map<String, Object> map = new HashMap<>(16);
  13. map.put("email", employee.getEmail());
  14. map.put("age", employee.getAge());
  15.  
  16. Integer result = employeeMapper.deleteByMap(map);
  17.  
  18. if (result != null || result > 0) {
  19. logger.info("++++++++++++++++删除成功+++++");
  20. }
  21.  
  22. }

4、根据条件构造器删除

  1. /**
  2. * 删除客户
  3. *
  4. * @throws SQLException
  5. */
  6. @Test
  7. public void deletedMethod() throws SQLException {
  8.  
  9. // 4.根据条件构造器删除
  10. Integer result = employeeMapper.delete(new QueryWrapper<Employee>()
  11. .eq("gender", 1));
  12.  
  13. if (result != null || result > 0) {
  14. logger.info("++++++++++++++++删除成功+++++");
  15. }

Mybatis-Plus 实战完整学习笔记(八)------delete测试的更多相关文章

  1. Mybatis-Plus 实战完整学习笔记(七)------select测试二

    1.查询selectOne  (3.0.3版) @Test public void selectMethod() throws SQLException { // 根据ID获取一个对象的数据 Empl ...

  2. Mybatis-Plus 实战完整学习笔记(六)------select测试一

    查询方法(3.0.3) 1.查询一个员工的数据 @Test public void selectMethod() throws SQLException { // 根据ID获取一个对象的数据 Empl ...

  3. Mybatis-Plus 实战完整学习笔记(五)------insert测试

    一.更新操作探究(3.0.3版本) demo /** * 修改用户 * @throws SQLException */ @Test public void update() throws SQLExc ...

  4. Mybatis-Plus 实战完整学习笔记(一)------简介

    第一章    简介      1. 什么是MybatisPlus                MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只 ...

  5. Mybatis-Plus 实战完整学习笔记(十一)------条件构造器删除,修改,conditon

    1.修改功能--其他过滤方式跟select一样 /** * 修改条件构造器 * @throws SQLException */ @Test public void selectUpdate() thr ...

  6. Mybatis-Plus 实战完整学习笔记(四)------全局参数配置

    一.全局配置设置 (1)全局配置Id自动生成 <!--定义mybatisplus全局配置--> <bean id="globalConfig" class=&qu ...

  7. Mybatis-Plus 实战完整学习笔记(三)------导入MybatisPlus环境

    1.dao层接口引入 package com.baidu.www.mplus.mapper; import com.baidu.www.mplus.bean.Employee; import com. ...

  8. Mybatis-Plus 实战完整学习笔记(二)------环境搭建

     第二章    使用实例   1.搭建测试数据库 -- 创建库 CREATE DATABASE mp; -- 使用库 USE mp; -- 创建表 CREATE TABLE tbl_employee( ...

  9. Mybatis-Plus 实战完整学习笔记(十)------条件构造器核心用法大全(下)

    31.升序orderByAsc 31.升序orderByAsc List<Employee> employeeList = employeeMapper.selectList(new Qu ...

随机推荐

  1. JAVA8 ARRAY、LIST操作 汇【5】)- JAVA8 LAMBDA LIST统计(求和、最大、最小、平均)

    public class Apple { private Integer id; private String name; private BigDecimal money; private Inte ...

  2. 662. Maximum Width of Binary Tree二叉树的最大宽度

    [抄题]: Given a binary tree, write a function to get the maximum width of the given tree. The width of ...

  3. 再遇ibatisNet

    11年在Mr刘的带领下第一次接触ibatisnet ,当时Mr刘很详细的很讲了xml里的写法还有配置文件之类的,但是随着时间越来越久远.很多东西都开始淡忘了. 如今,再次和它相遇,依然觉得很亲切,虽然 ...

  4. linux命令学习之:passwd

    passwd命令用于设置用户的认证信息,包括用户密码.密码过期时间等.系统管理者则能用它管理系统用户的密码.只有管理者可以指定用户名称,一般用户只能变更自己的密码. 语法 passwd(选项)(参数) ...

  5. Exception starting filter encodingFilter

    1. maven运行tomcat6出现错误Exception starting filter encodingFilter: 严重: Exception starting filter encodin ...

  6. linux高级编程——IO

    1,文件IO 1)open——打开或创建一个文件 open(char *,flag,mode)在fcntl.h文件中声明. 参数: char * 包含有文件名和路径 flag 打开文件方式 mode ...

  7. MySQL优化(一) 优化关键技术

    MySql的优化是一个综合性的技术,主要包括有: (1)表的设计合理化(符合 3NF 三范式) (2)添加适当的索引(Index):索引分类:普通索引.主键索引.唯一索引.全文索引(文本).空间索引. ...

  8. Contest with Drinks Easy

    /* Problem Statement Joisino is about to compete in the final round of a certain programming competi ...

  9. spec文件写作规范

    spec文件写作规范 2008-09-28 11:52:17 分类: LINUX 1.The RPM system assumes five RPM directories BUILD:rpmbuil ...

  10. 使用Trinity拼接以及分析差异表达一个小例子

    使用Trinity拼接以及分析差异表达一个小例子  2017-06-12 09:42:47     293     0     0 Trinity 将测序数据分为许多独立的de Brujin grap ...