mybatis bug之resultmap缺少object-relation匹配参数password,造成设置密码不成功
1.mybatis bug之resultmap缺少object-relation匹配参数password,造成设置密码不成功
在resultmap里没有设置user类中password属性和数据库表tbl_user的password字段的匹配,造成在执行update的操作时候,无法把user中的password更新到数据库表中。
解:userMapper.xml
<resultMap id="BaseResultMap" type="User" extends="SimpleResultMap"> <id property="uid" column="uid" /> <result property="unionid" column="unionid"/> <result property="openid" column="openid"/> <result property="age" column="age"/> <result property="birthday" column="birthday"/> <result property="sex" column="sex"/> <result property="phone" column="phone"/> <result property="email" column="email"/> <result property="qq" column="qq"/> <result property="wechat" column="wechat"/> <result property="province" column="province"/> <result property="city" column="city"/> <result property="country" column="country"/> <result property="channel" column="channel"/> <result property="password" column="password"/> <!-- SimpleResultMap 中已经有 <result property="nickname" column="nickname"/> <result property="headimgurl" column="headimgurl"/> <result property="appid" column="appid"/> <result property="password" column="password"/> --> <result property="backgroundimg" column="backgroundimg"/> <result property="description" column="description"/> <result property="createTime" column="create_time"/> </resultMap> <resultMap id="SimpleResultMap" type="User"> <id property="uid" column="uid" /> <result property="nickname" column="nickname"/> <result property="headimgurl" column="headimgurl"/> </resultMap>
<update id="update">
update tbl_user
<set>
<trim suffixOverrides=",">
<if test="phone != null">
phone = #{phone},
</if>
<if test="age != null">
age = #{age},
</if>
<if test="birthday != null">
birthday = #{birthday},
</if>
<if test="email != null">
email = #{email},
</if>
<if test="qq != null">
qq = #{qq},
</if>
<if test="wechat != null">
wechat = #{wechat},
</if>
<if test="sex != null">
sex = #{sex},
</if>
<if test="nickname != null">
nickname = #{nickname},
</if>
<if test="province != null">
province = #{province},
</if>
<if test="headimgurl != null">
headimgurl = #{headimgurl},
</if>
<if test="city != null">
city = #{city},
</if>
<if test="password != null">
password = #{password},
</if>
<if test="backgroundimg != null">
backgroundimg = #{backgroundimg},
</if>
<if test="description != null">
description = #{description},
</if>
</trim>
</set>
<where>
uid = #{uid}
</where>
</update>