本文最后更新于25 天前,其中的信息可能已经过时,如有错误请发送邮件到2260856635@qq.com
5.1、resultMap 自定义映射
- ResultMap 的设计思想是,对于简单的语句根本不需要配置显式的结果映射,而对于复杂一点的语句只需要描述它们的关系就行了。
- 、自定义resultMap,实现高级结果集映射
- 、id :用于完成主键值的映射
- 、result :用于完成普通列的映射
- 、association :一个复杂的类型关联;许多结果将包成这种类型
- 、collection : 复杂类型的集
<resultMap id="UserMap" type="User">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="password" column="pwd"/>
</resultMap>
<select id="getUserById" parameterType="int" resultMap="UserMap">
select * from mybatis.user where id = #{id}
</select>