Mybatis中resultMap的几个子标签

public class User implements Serializable { 
 
 private Integer id;  
 private String username;  
 private Date birthday;  
 private String sex;  
 private String address;    

 **private List<Account> accounts**     //在User中关联了Account信息
          
     ......
 }

配置文件

<resultMap type="user" id="userMap">   
	<id column="id" property="id"></id>  
	<result column="username" property="username"/>   
	<result column="address" property="address"/>   
	<result column="sex" property="sex"/>   
	<result column="birthday" property="birthday"/>   
	<!-- collection 是用于建立一对多中集合属性的对应关系    
	ofType 用于指定集合元素的数据类型    --> 
	<collection property="accounts" ofType="account">    
		<id column="aid" property="id"/>    
		<result column="uid" property="uid"/>    
		<result column="money" property="money"/> 
	</collection>  
</resultMap

collection 部分定义了用户关联的账户信息。表示关联查询结果集

property=“accList” :
关联查询的结果集存储在 User 对象的上哪个属性。
ofType=“account” :
指定关联查询的结果集中的对象类型即List中的对象类型。此处可以使用别名,也可以使用全限定名

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值