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

  • 相关阅读:
    mysql日期计算转换
    Mysql的DATE_FORMAT()日期格式转换
    JDBC连接池BoneCP
    JSP之三大指令
    JSP的三大指令 七大动作 九大对象
    JSP的语法
    orcale序列操作
    Orcale约束-------外键约束
    Orcale约束-------檢查約束
    Orcale约束-------主键约束
  • 原文地址:https://www.cnblogs.com/2016024291-/p/8248127.html
Copyright © 2011-2022 走看看