mybatis 关联查询 association

    <resultMap id="DutyPersonAndFileAndScoreMap" type="com.cares.asis.duty.entity.DutyPersonAndFileAndScoreVO">
        <id column="DUTY_ID" property="dutyId" jdbcType="DECIMAL" />
        <association property="file" column="{flightDate=FLIGHT_DATE,flightNo=FLIGHT_NO}" select="com.cares.asis.duty.dao.EvidencePersonFileMapper.findEvidencePersonFiles"></association>
    </resultMap>
    <select id="findDutyDetail" resultMap="DutyPersonAndFileAndScoreMap" parameterType="java.util.Map">
        select duty_id from a 
    </select>
select 返回map ,map 中使用 association 关联查询 ,返回值要对应map 中的属性(file).. 参数为column 可以是单参数(直接column = "flightDate"即可) 也可以多参数类似 上面,
使用多参数 select 方法参数一定要用Map. (select 可以直接关联另一个select 语句 ,也可以关联mapper方法(即与mapper 关联的dao 接口中的方法)) 。。
原文地址:https://www.cnblogs.com/zhangchenglzhao/p/5514920.html