Mybatis结果集ResultMap映射

解决属性名和数据库字段名不一致的问题

  1. 基本使用:
<resultMap id="user" type="com.guan.bean.UserBean">
    <result column="UPassword" property="password"></result>
</resultMap>

<select id="getUserList" resultMap="user" parameterType="map">
    select * from user LIMIT #{startIndex},#{numIndex}
</select>

注:(1).select标签通过resultMap绑定id为user的resultMap标签
(2).resultMap标签通过id属性进行申明,通过type属性绑定限定类名
(3).对数据库中的字段column向Bean中的属性property做映射(这里只要写数据库中的字段名和Bean中的属性名不同的部分即可)

猜你喜欢

转载自www.cnblogs.com/Arno-vc/p/13364754.html