先主查询,再关联子查询,不影响分页效果,否则子查询也会参与分页。
<resultMap id="Hdr" type="com.Hdr">
<id column="crh_id" property="id" javaType="int"/>
<collection property="DtlList"
select="queryAllRmdDetail"
column="crh_id"
fetchType="eager">
</collection>
</resultMap>
<resultMap id="Dtl" type="com.Dtl">
</resultMap>
主查询:
<select id="queryByCondition" parameterType="String" resultMap="Hdr">
</select>
在主查询后,通过传入主键id进行关联子查询:
<select id="queryAllDetail" parameterType="int" resultMap="Dtl">
SELECT * FROM biz_dtl WHERE crh_id = #{id}
</select>
主查询的结果是List,以及每一条记录的内涵List,性能是N+1次查询。
如果提高查询性能,

最低0.47元/天 解锁文章
2242

被折叠的 条评论
为什么被折叠?



