MyBatis-Plus 的简单查询

一 数据库

mysql> select * from user;
+---------------------+--------------+------+--------------------+---------------------+---------------------+---------+
| id                  | NAME         | age  | email              | create_time         | update_time         | version |
+---------------------+--------------+------+--------------------+---------------------+---------------------+---------+
|                   0 | auto         |   20 | 1243@qq.com        | NULL                | NULL                |    NULL |
|                   1 | Jone         |   18 | test1@baomidou.com | NULL                | NULL                |    NULL |
|                   2 | Jack         |   20 | test2@baomidou.com | NULL                | NULL                |    NULL |
|                   3 | Tom          |   28 | test3@baomidou.com | NULL                | NULL                |    NULL |
|                   4 | Sandy        |   21 | test4@baomidou.com | NULL                | NULL                |    NULL |
|                   5 | Billie       |   24 | test5@baomidou.com | NULL                | NULL                |    NULL |
| 1443158688033337346 | lucymaryupup |   20 | 1243@qq.com        | NULL                | 2021-09-30 08:51:12 |    NULL |
| 1443378040145903617 | ASSIGN_ID    |   20 | 1243@qq.com        | 2021-09-30 08:51:56 | 2021-09-30 08:51:56 |    NULL |
| 1444192337759502338 | zhangsan     |   20 | 1243@qq.com        | 2021-10-02 14:47:40 | 2021-10-02 14:55:10 |       2 |
+---------------------+--------------+------+--------------------+---------------------+---------------------+---------+

二 根据id删除记录

1 测试代码

// 根据 id 删除
@Test
public void testDeleteId() {
    int rows = userMapper.deleteById(1444192337759502338L);
    System.out.println(rows);
}

2 测试结果

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a0df195] was not registered for synchronization because synchronization is not active
2021-10-02 16:28:36.039  INFO 17328 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-10-02 16:28:37.808  INFO 17328 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
JDBC Connection [HikariProxyConnection@605600260 wrapping com.mysql.cj.jdbc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值