一、一对多查询
 A表与B表是一对多关系:
 A表
| a | ad | 
|---|---|
| 1 | 1 | 
B表
| b | a_id | 
|---|---|
| 1 | 1 | 
| 2 | 1 | 
| 3 | 1 | 
A表对应的实体类EntityA,B表对应的实体类EntityB
public class EntityA {
	private Integer a;
	private Integer ad;
}
public class EntityB{
	private Integer b;
	private Integer aId;
}
public class EntityAVo {
	private Integer a;
	private Integer ad;
	private List<EntityB> alist;
}
mybatis文件
<resultMap id="aMap" type="EntityAVo">
	<result property="a" column="a"/>
	<result property="ad" column="ad"/>
	<collection property="alist" ofType="EntityB">
		<result column="b" property="b"/>
		<result column="a_id" property="aId"/>
	</collection>
</resultMap>
<select id="test" resultMap="aMap">
	SELECT 
		A.a,
		A.ad,
		B.b,
		B.a_id
	FROM
	A
	LEFT JOIN B ON B.a_id = A.a
</select>
返回的实体结构
EntityAVo 
 a=1
 ad=1
 alist=List<EntityB>
 	b=1,aId=1
 	b=2,aId=1
 	b=3,aId=1
例如下图











