MyBatis(10)使用association进行分步查询

Posted 司徒二条

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyBatis(10)使用association进行分步查询相关的知识,希望对你有一定的参考价值。

(1)接口中编写方法

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

(2)Mapper文件

 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>

 

以上是关于MyBatis(10)使用association进行分步查询的主要内容,如果未能解决你的问题,请参考以下文章