zoukankan      html  css  js  c++  java
  • Mapper.xml中的resultMap

    1.实体类

     1     class Company{
     2         private String c_id ;
     3         private String c_name ;
     4         private String c_address ;
     5         private String c_type ;
     6         private Dept dept =new Dept();//记得new 不然xml文件会报null
     7         private Role role =new Role();//记得new 不然xml文件会报null
     8         .....
     9     }
    10     class Dept{
    11         private String d_id ;
    12         private String d_name ;
    13         private String d_num ;
    14         .....
    15     }
    16     class Role{
    17         private String r_id ;
    18         private String r_name ;
    19         private String r_num ;
    20         .....
    21     }
    22     

    2.xxMapper.xml中的Map写法

      <resultMap ik="companyMap" type="com.ss.syf.domain.Company">
                    <id column="c_id" property="c_id"/>                 
                    <result column="c_name" property="c_name"/>    
                    <result column="c_address" property="c_address"/>    
                    <result column="c_type" property="c_type"/>       
            <collection property="dept" ofType="com.ss.syf.domain.Dept">
                    <id column="d_id" property="d_id"/>
                    <result column="d_name" property="d_name"/>
                    <result column="d_num" property="d_num"/>
            </collection>
            <collection property="role" ofType="com.ss.syf.domain.Role">
                    <id column="r_id" property="r_id"/>
                    <result column="r_name" property="r_name"/>
                    <result column="r_num" property="r_num"/>
            </collection>
        </resultMap>
  • 相关阅读:
    多变的鸭子策略模式
    反序列化和序列化
    UBUNTU eclipse必须是 jdk5.0以上
    Ubuntu Linux:MySQL安装指南
    phpMyAdmin下载、安装和使用入门
    读者-写者问题
    wget用法2
    在linux下安装mysql
    linux下数字转成字符串
    [SQLServer]必须知道的SQL
  • 原文地址:https://www.cnblogs.com/janesyf/p/8144050.html
Copyright © 2011-2022 走看看