QHYxx 2022-03-19 18:11 采纳率: 66.7%
浏览 35
已结题

MybatisPlus 可以插入,读取表中内容 不能删除

可以插入,读取表中内容 不能删除
@SpringBootTest
public class PetsitterTest {

    @Autowired
    public UserMapper userMapper;

    @Test
    public void select () {
        List<user> list = userMapper.selectList(null);
        for (Object object : list) {
            System.out.println(object);
        }
    }

    @Test
    public void inster (){
        //新增用户信息
        //INSERT INTO user ( user_psw, user_id, user_name, user_img ) VALUES ( ?, ?, ?, ? )
            user user = new user();
            user.setUser_id(19);
            user.setUser_name("nuibi");
            user.setUser_psw("123456");
            user.setUser_img("haokan");
            int insert = userMapper.insert(user);
            System.out.println("受影响的行数:" + insert);
        System.out.println("id:"+user.getUser_id());
        }

    @Test
    public void delete(){
        List<Long> list = Arrays.asList(1L, 2L);
        int i = userMapper.deleteById(19L);
        //int i = userMapper.deleteBatchIds(list);
        System.out.println("删除了:"+i);

    }



    }

不会报错

Warn: Could not find @TableId in Class: com.example.pojo.user.
2022-03-19 18:08:59.317  INFO 11708 --- [           main] com.example.PetsitterTest                : Started PetsitterTest in 2.556 seconds (JVM running for 3.694)
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@ffd4cba] was not registered for synchronization because synchronization is not active
2022-03-19 18:08:59.574  INFO 11708 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-03-19 18:08:59.775  INFO 11708 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
JDBC Connection [HikariProxyConnection@2043889470 wrapping com.mysql.cj.jdbc.ConnectionImpl@4dad0eed] will not be managed by Spring
==>  Preparing: DELETE FROM user WHERE null=? 
==> Parameters: 1(Long)
<==    Updates: 0
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@ffd4cba]
删除了:0
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@fd09e43] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1510312933 wrapping com.mysql.cj.jdbc.ConnectionImpl@4dad0eed] will not be managed by Spring
==>  Preparing: INSERT INTO user ( user_psw, user_id, user_name, user_img ) VALUES ( ?, ?, ?, ? ) 
==> Parameters: 123456(String), 101(Long), nuibi(String), haokan(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@fd09e43]
受影响的行数:1
id:101
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@52ea0269] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@2062828451 wrapping com.mysql.cj.jdbc.ConnectionImpl@4dad0eed] will not be managed by Spring
==>  Preparing: SELECT user_psw,user_id,user_name,user_img FROM user 
==> Parameters: 
<==    Columns: user_psw, user_id, user_name, user_img
<==        Row: 123456, 1, qhy, quh
<==        Row: 123456, 2, qhy, quh
<==        Row: 123456, 3, qhy, quh
<==        Row: 123456, 5, nuibi, haokan
<==        Row: 123456, 9, nuibi, haokan
<==        Row: 123456, 10, nuibi, haokan
<==        Row: 123456, 11, nuibi, haokan
<==        Row: 123456, 14, nuibi, haokan
<==        Row: 123456, 15, nuibi, haokan
<==        Row: 123456, 19, nuibi, haokan
<==        Row: 123456, 100, nuibi, haokan
<==        Row: 123456, 101, nuibi, haokan
<==      Total: 12
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@52ea0269]
user(user_id=1, user_img=quh, user_name=qhy, user_psw=123456)
user(user_id=2, user_img=quh, user_name=qhy, user_psw=123456)
user(user_id=3, user_img=quh, user_name=qhy, user_psw=123456)
user(user_id=5, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=9, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=10, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=11, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=14, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=15, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=19, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=100, user_img=haokan, user_name=nuibi, user_psw=123456)
user(user_id=101, user_img=haokan, user_name=nuibi, user_psw=123456)

解决不了 ~

  • 写回答

1条回答 默认 最新

  • wyz0923 2022-03-19 18:22
    关注

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 3月27日
  • 已采纳回答 3月19日
  • 创建了问题 3月19日

悬赏问题

  • ¥15 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?