(1)接口中编写方法
1 public Emp getEmpandDept();
(2)编写Mapper文件
1 <resultMap type="com.eu.bean.Emp" id="emp2"> 2 <id column="id" property="id"/> 3 <result column="last_name" property="lastName"/> 4 <result column="gender" property="geder"/> 5 <result column="email" property="email"/> 6 <result column="id" property="dept.id"/> 7 <result column="dept_name" property="dept.deptName"/> 8 </resultMap> 9 10 <select id="getEmpandDept" resultMap="emp2"> 11 SELECT * 12 FROM emp e 13 JOIN dept d 14 ON e.d_id=d.id 15 </select>