我的实体类属性如下:
public class CheckRecordVO {
private Long id;
private Long pointId;
private String pointName;
private List<String> picture;
}
Mapper.xml如下:
<resultMap id="CheckRecordResultMap" type="cn.test.user.pojo.vo.CheckRecordVO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="point_id" jdbcType="BIGINT" property="pointId" />
<result column="point_name" jdbcType="VARCHAR" property="pointName" />
<collection property="picture" resultMap="pictureList"/>
</resultMap>
<resultMap id="pictureList" type="java.lang.String">
<result column="url"/>
</resultMap>
<select id="selectCheckRecord" resultMap="CheckRecordResultMap">
select cr.id, cr.point_id, cp.point_name,i.url
from check_record cr
left join check_point cp on cp.point_id = cr.point_id
left join check_record_image cri on cri.check_record_id = cr.id
left join image i on i.id = cri.image_id
where cr.id = #{id}
</select>
以上是我的解决方案;
总结一下就是collection的用法,