美文网首页
association与collection多column传递

association与collection多column传递

作者: Man_10 | 来源:发表于2020-04-02 15:09 被阅读0次
    <resultMap id="QueryMonthPageVO" type="com.wx.cspl.mip.model.vo.SuperviseTaskMonthReportVO">
            <result column="id" property="id"/>
            <result column="orgseq" property="orgSeq"/>
            <result column="yearParticular" property="year"/>
            <result column="monthParticular" property="month"/>
            <result column="task_name" property="taskName"/>
            <result column="report" property="monthDetail"/>
            <result column="complete_status" property="finishCode"/>
            <result column="finish_rate" property="progressBar"/>
            <result column="question" property="question"/>
            <result column="measures" property="measures"/>
            <result column="update_time" property="updateTime"/>
            <result column="year_plan_id" property="yearPlanId"/>
            <result column="season" property="season"/>
            <!-- 级联查询季度 -->
            <association property="quarterTarget" column="{yearPlanId= year_plan_id, season = season}"
                         select="com.wx.cspl.mip.dao.QuarterMapper.getQuarter" />
        </resultMap>
    

    其中
    <association property="quarterTarget" column="{yearPlanId= year_plan_id, season = season}"
    select="com.wx.cspl.mip.dao.QuarterMapper.getQuarter" />

    以key:value的形式传递值

    value = year_plan_id与value = season对应resultMap里面的column字段 <result column="year_plan_id" property="yearPlanId"/>
    <result column="season" property="season"/>

    以map的形式传值

    /** 根据yearPlanId与Season查询季度目标 */
        Quarter getQuarter(Map<String,Object> map);
    

    year_plan_id = #{yearPlanId} and season = #{season}
    #{yearPlanId}与#{season} 对应map的key
    parameterType="java.util.Map"
    注意参数类型为map

    <!-- 根据yearPlanId与Season查询季度目标 -->
        <select id="getQuarter" resultType="com.wx.cspl.mip.model.entity.Quarter" parameterType="java.util.Map">
          select * from t_quarter where year_plan_id = #{yearPlanId} and season = #{season}
        </select>
    

    相关文章

      网友评论

          本文标题:association与collection多column传递

          本文链接:https://www.haomeiwen.com/subject/hjsxphtx.html