1 <resultMap id="deplist" type="DepList">
2 <id property="dId" column="d_id"></id>
3 <result property="dName" column="d_name"></result>
4 <collection property="list" select="mapper.empMapper.selectById" column="d_id">
5 </collection>
6 </resultMap>
7 <select id="selectById" resultMap="deplist">
8 select *
9 from dep
10 where d_id = #{id}
11 </select>
<resultMap id="em" type="emp"> <!-- 缺少这部分映射关系会导致结果list中的元素都为 null -->
<id property="eId" column="e_id"></id>
<result property="eName" column="e_name"></result>
<result property="dId" column="e_d"></result>
</resultMap>
<select id="selectById" resultMap="em">
select * from emp where e_d = #{id}
</select>