码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-04-21 14:45:35      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:r文件   查询   email   end   编写   div   code   color   dep   

(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进行分步查询

标签:r文件   查询   email   end   编写   div   code   color   dep   

原文地址:https://www.cnblogs.com/wanerhu/p/10744966.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!