mybatis Map和模糊查询

一、Map(万能)多用于实际生产环境

1、字段过多的情况 update

2、多条件 查询

3、sql语句,只需要几个有用的字段

例子

update

接口类

int updateUser2(Map<String, Object> map);

xml

    <update id="updateUser2" parameterType="map">
        update mybatis.user set name = #{isNmae}  where id = #{isId};
    </update>

测试

  @Test
  public void updateUserMap(){
       SqlSession sqlSession = MyBatisUtil.getSession();
       UserDao userDao = sqlSession.getMapper(UserDao.class);
       Map<String, Object> map = new HashMap<String, Object>();
       map.put("isNmae", "wutong");
       map.put("isId", 1);
       userDao.updateUser2(map);
       sqlSession.commit();
       sqlSession.close();
  }

二、模糊查询

原文地址:https://www.cnblogs.com/wt7018/p/13330363.html