接口
//更新数据
int updateBlog(Map map);
接口配置文件
<update id="updateBlog" parameterType="map">
update mybatis.blog
<set>
<if test="title!=null">
title=#{title},
</if>
<if test="author">
author=#{author}
</if>
</set>
where id=#{id}
<trim prefix=" " prefixOverrides="" suffix=" " suffixOverrides=""></trim>
</update>
测试类
@Test
public void getBlogIF(){
SqlSession sqlSession = MybatisUtils.getSqlSession ();
BlogMapper mapper = sqlSession.getMapper (BlogMapper.class);
HashMap map = new HashMap ();
map.put ("title","狂神说JAVA2");
map.put ("id","9f56ae230e5c4c8a971cebbbe64b895c");
int i = mapper.updateBlog (map);
sqlSession.close ();
}