springboot——Mapper.xml中的resultMap
作者:互联网
1.实体类
1 class Company{ 2 private String c_id ; //对应数据库中的PKEY 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 ; //对应数据库中的PKEY 12 private String d_name ; 13 private String d_num ; 14 ..... 15 } 16 class Role{ 17 private String r_id ; //对应数据库中的PKEY 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>
标签:xml,Mapper,springboot,PKEY,private,.....,new,String 来源: https://www.cnblogs.com/nana-qiu/p/11661093.html