通过map传递参数
UserMapper
public int updateUserByMap(Map map);
UserMapper.xml
<update id="updateUserByMap" parameterType="map">
update mybatis.user set name=#{username} where id=#{id};
</update>
Test
@Test
public void testUpUserByMap(){
//第一步:获得sqlSession对象
SqlSession sqlSession = MybatisUtils.getSqlSession();
//第二步:执行sql
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
HashMap<String, Object> map = new HashMap<>();
map.put("username","乔晓斌");
map.put("id",1);
mapper.updateUserByMap(map);
sqlSession.commit();
//第三步:关闭sqlSession
sqlSession.close();
}