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:指定这个属性的类型

  • 相关阅读:
    hdu5002 Tree
    hdu6858(杭电多校第八场) Discovery of Cycles
    杭电多校第八场总结
    ubuntu刷新swap
    python 如何关闭warning的输出
    python 如何获取整数,浮点数的最大值
    补码
    LaTeX 公式集锦
    Codeforces 581D Three Logos
    Codeforces 582 A. GCD Table
  • 原文地址:https://www.cnblogs.com/2016024291-/p/8248127.html
Copyright © 2011-2022 走看看