使用场景,针对的是 一对多的情况
用法
实体类
public class good{
private String id;
private String goodName;
private List<info> infoList;
}
public class info{
private String id;
private Stirng name;
}
mapper.xml
<resultMap id="BaseMap" type="good" >
<result column="id" jdbcType="VARCHAR" property="id">
<result column="good_name" jdbcType="VARCHAR" property="goodName">
<collection property="infoList" ofType="info">
<result column="b_id" jdbcType="VARCHAR" property="id">
<result column="b_name" jdbcType="VARCHAR" property="name">
</collection>
</resultMap>
<Select id="selectAll" resultMap="BaseMap">
select a.id,a.good_name,b.id as b_id,b.name as b_name from A a left jion B b on a.id=b.infoId
</Select>