zoukankan      html  css  js  c++  java
  • resultMap2_关联查询2_association定义关联对象封装规

    EmployeeMapperPlus.xml代码对比

      ①方法一:

    <resultMap type="com.atguigu.mybatis.bean.Employee" id="MyDifEmp">
            <id column="id" property="id"/>
            <result column="email" property="email"/>
            <result column="last_name" property="lastName"/>
            <result column="gender" property="gender"/>
            <result column="did" property="dept.id"/>
            <result column="dept_name" property="dept.departmentName"/>
        </resultMap>

       ②方法二:

    <resultMap type="com.atguigu.mybatis.bean.Employee" id="MyDifEmp2">
            <id column="id" property="id"/>
            <result column="email" property="email"/>
            <result column="last_name" property="lastName"/>
            <result column="gender" property="gender"/>
            <!-- 
                association可以指定联合的JavaBean对象
                property=“dept”:指定哪个属性是联合的对象
                JavaType:指定这个属性的类型
             -->
            <association property="dept" javaType="com.atguigu.mybatis.bean.Department">
                <id column="did" property="id"/>
                <result column="dept_name" property="departmentName"/>
            </association>
            
        </resultMap>

     注:association可以指定联合的JavaBean对象

       property=“dept”:指定哪个属性是联合的对象

       JavaType:指定这个属性的类型

  • 相关阅读:
    VMware Workstation 16.0 key (仅支持 intel 架构)
    使用思科ASA对指定端口、IP进行抓包
    轮子的意义
    dubbo学习(三)泛化
    dubbo学习(二)链接
    dubbo学习(一)线程池
    mips交叉编译:SQLite3
    生成证书脚本
    ssh连接不上 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
    gmssl ocsp 验证证书
  • 原文地址:https://www.cnblogs.com/2016024291-/p/8248127.html
Copyright © 2011-2022 走看看