一、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();
  }

二、模糊查询

相关文章:

  • 2021-09-02
  • 2021-08-04
  • 2022-12-23
  • 2021-05-29
  • 2021-07-12
  • 2021-10-16
  • 2021-10-16
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2021-05-28
  • 2021-08-06
  • 2022-03-08
相关资源
相似解决方案