一. 例子
EmployeeMapperResultMap.xml
<!--自定义映射
type:指定结果集的封装类型
<id>:封装主键列
column: 结果集的列名
property: 封装的对象的属性名
<result>:封装普通列
eid last_name email gender did dept_name
1001 刚哥 gg@sina.com 1 1 开发部
-->
<resultMap type="com.atguigu.mybatis.beans.Employee" id="myEmpAndDept">
<id column="eid" property="id"/>
<result column="last_name" property="lastName"/>
<result column="email" property="email"/>
<result column="gender" property="gender"/>
<!-- <result column="did" property="dept.id"/>
<result column="dept_name" property="dept.departmentName"/> -->
<!--
association: 联合,关联
property: 指定关联属性名
javaType:指定关联属性类型
-->
<association property="dept" javaType="com.atguigu.mybatis.beans.Department">
<id column="did" property="id"/>
<result column="dept_name" property="departmentName"/>
</association>
</resultMap>