其他分享
首页 > 其他分享> > 万能的Map以及模糊查询

万能的Map以及模糊查询

作者:互联网

万能的Map以及模糊查询

1.0 UserMapper文件

User getUserById2(Map<String, Object> map);

1.1 UserMapper.xml 文件

<select id="getUserById2" parameterType="map" resultType="com.chris.pojo.User">
    select * from chrisdb.zd_user where ID = #{ids}
</select>

1.2 junit测试单元文件

@Test
    public void test05() {
        SqlSession sqlSession = null;
        try {
            sqlSession = MybatisUtils.getSqlSession();
            UserMapper mapper = sqlSession.getMapper(UserMapper.class);
            Map<String, Object> map = new HashMap<>();
            map.put("ids", 1);
            User userById2 = mapper.getUserById2(map);
            System.out.println(userById2);
        } catch (Exception exception) {
            System.out.println(exception.getMessage());
        } finally {
            sqlSession.close();
        }
    }

1.3使用Map好处

标签:Map,map,万能,UserMapper,System,查询,sqlSession,User
来源: https://www.cnblogs.com/wooroc/p/16078775.html