(1)接口中编写方法

public Emp getEmpByStep(Integer id);
public Dept getDeptById(Integer id);

(2)Mapper文件

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
 1   <!-- 使用association进行分步查询 -->
 2   <resultMap type="com.eu.bean.Emp" id="MyStep">
 3       <id column="id" property="id"/>
 4       <result column="last_name" property="lastName"/>
 5       <result column="gender" property="geder"/>
 6       <result column="email" property="email"/>
 7       <association property="dept" 
 8       select="com.eu.dao.DeptDao.getDeptById"
 9       column="d_id">
10       </association>
11   </resultMap>
12  <select id="getEmpByStep" resultMap="MyStep">
13       select * from emp where id = #{id}
14   </select>

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄