mybatis 关联查询 association

Posted 远方的人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 接口中的方法)) 。。

 

以上是关于mybatis 关联查询 association的主要内容,如果未能解决你的问题,请参考以下文章

MyBatis高级篇 - 关联查询(一对多)

MyBatis_关联关系查询

MyBatis的关联查询

MyBatis关联查询 (association) 时遇到的某些问题/mybatis映射

MyBatis关联查询,一对多关联查询

mybatis中的关联查询