zoukankan      html  css  js  c++  java
  • 使用collection:分段查询结果集

    1.在人员接口书写方法

    public List<Employee> getEmpsByDeptId(Integer deptId);

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

    <!-- public List<Employee> getEmpsByDeptId(Integer deptId); -->
    <select id="getEmpsByDeptId" resultType="com.atguigu.mybatis.bean.Employee">
    select * from tbl_employee where did=#{deptId}
    </select>

    3在部门中接口书写方法

    public Department getDeptByIdStep(Integer id);

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

    <!-- collection:分段查询 -->
    <resultMap type="com.atguigu.mybatis.bean.Department" id="MyDeptStep">
    <id column="id" property="id"/>
    <id column="dname" property="departmentName"/>

    <!-- 扩展:多列的值传递过去:
    将多列的值封装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 id="getDeptByIdStep" resultMap="MyDeptStep">
    select id,dname from department where id=#{id}
    </select>


  • 相关阅读:
    Java + Element-UI 实现简单的树形菜单
    简单了解一下 Nginx
    使用阿里云 OSS 存储、访问图片(Java)
    JSR 303 进行后台数据校验
    SpringBoot 常用注解
    12、js——轮播图
    11、js——定时调用和延时调用
    11、js——BOM
    10、js——事件
    9、js——样式相关的操作
  • 原文地址:https://www.cnblogs.com/zhangzhiqin/p/8549161.html
Copyright © 2011-2022 走看看