1.在人员接口书写方法

public List<Employee> getEmpsByDeptId(Integer deptId);

2在人员映射文件中进行配置

<!-- public List<Employee> getEmpsByDeptId(Integer deptId); -->
<select >
select * from tbl_employee where did=#{deptId}
</select>

3在部门中接口书写方法

public Department getDeptByIdStep(Integer id);

2在部门映射文件中进行配置

<!-- collection:分段查询 -->
<resultMap type="com.atguigu.mybatis.bean.Department" />

<!-- 扩展:多列的值传递过去:
将多列的值封装map传递;
column="{key1=column1,key2=column2}"
fetchType="lazy":表示使用延迟加载;
- lazy:延迟
- eager:立即
-->


<collection property="emps"
select="com.atguigu.mybatis.dao.EmployeeMapperPlus.getEmpsByDeptId"
column="{deptId=id}" fetchType="lazy"></collection>
</resultMap>
<!-- public Department getDeptByIdStep(Integer id); -->
<select >
select id,dname from department where id=#{id}
</select>


相关文章:

  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2021-08-25
猜你喜欢
  • 2021-09-26
  • 2021-08-07
  • 2022-12-23
  • 2021-11-13
  • 2021-09-25
相关资源
相似解决方案