<resultMap id="UserPhotoMap" type="com.example.user.bean.UserPhotoMsg">
<id column="id" property="id" />
<result column="account" property="account" />
<result column="name" property="name" />
<result column="sex" property="sex" />
//嵌套查询语句collection中的column属性,是需要传入嵌套sql中的参数,参数必须是外层中有的字段
//可以多个参数,也可以单个参数
//多参形式:如 photoUserId=id,photoName=name
//参数相当于把id赋于photoUserId,name赋于photoName
//在嵌套sql中就可以使用被赋予的属性名称#{photoUserId},#{photoName}
// collection中的select属性是写嵌套sql的映射位置,位置是嵌套sql在项目中的mapper层的方法名称
<collection property="photoMessage" select="com.example.user.mapper.UserMapper.showPhotos" column="id">
</collection>
</resultMap>
<select id="showUserList" resultMap&#
mybatis中的collection嵌套sql查询
最新推荐文章于 2024-07-16 10:28:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)