mybatis02 --- 一对多,collection中嵌套select

时间:2024-04-15 10:43:40
    <resultMap id="getUnSendTemplateMessagesMap" extends="baseMap"
               type="cn.kz.b1.common.model.wechat.WechatTemplateMessage">
        <collection column="id" property="users" select="getTemplateUsers"></collection>
    </resultMap>

    <select id="getTemplateUsers" resultMap="templateUser">
        SELECT template_id,user_id,openid ,app_id,unionid,wx_openid,student_id,realname,status
        FROM xx_template_user
        WHERE template_id = #{id}
    </select>

    <select id="getUnSendTemplateMessages" resultMap="getUnSendTemplateMessagesMap">
        SELECT id,UUID,school_id,TYPE,STATUS,title,type_name,
                content,params,remark,create_person,create_time,modify_time,modify_person
        FROM xx_template_message
        WHERE status = 0
    </select>
    <resultMap id="ExamResultMapCondition" type="cn.kiway.czgj.common.vo.clazz.CzgjExaminationVo"
               extends="BaseResultMap">
        <result column="createPersonName" property="createPersonName"/>
        <result column="classId" property="classId"/>
        <!-- examinationId是当前map获得的参数;id是入参,外循环传入-->
        <collection column="{examinationId=id,classId=classId}" property="classList" 
                    select="selectExamClassByExamIdClassId" javaType="ArrayList"/>
        <collection column="{examinationId=id}" property="subjectList" select="selectExamSubject" javaType="ArrayList"/>
    </resultMap>