mybatisplus----CRUD操作之查询操作

    @Test
//根据id查询单个结果
    void testSelect1() {
        User user = userMapper.selectById(1L);
        System.out.println(user);


    }

    @Test
//根据多个id查询多个结果
    void testSelect2() {
        List<User> users = userMapper.selectBatchIds(Arrays.asList(1L, 2L, 3L));
        users.forEach(System.out::println);


    }

    @Test
//map条件查询
    void testSelect3() {
        HashMap<String, Object> map = new HashMap<String,Object>();
        map.put("name", "瓜瓜");
        map.put("age",3);
        List<User> users = userMapper.selectByMap(map);
        users.forEach(System.out::println);

    }

 

posted @ 2020-11-13 15:22  Joker-0927  阅读(100)  评论(0编辑  收藏  举报
// 侧边栏目录