
(1)接口中编写方法
public Emp getEmpByStep(Integer id);
public Dept getDeptById(Integer id);
(2)Mapper文件
<!-- 使用association进行分步查询 -->
<resultMap type="com.eu.bean.Emp" id="MyStep">
<id column="id" property="id"/>
<result column="last_name" property="lastName"/>
<result column="gender" property="geder"/>
<result column="email" property="email"/>
<association property="dept"
select="com.eu.dao.DeptDao.getDeptById"
column="d_id">
</association>
</resultMap>
<select id="getEmpByStep" resultMap="MyStep">
select * from emp where id = #{id}
</select>