mybatis返回实体参数嵌套方法,通过resultMap

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.jf.exmpe.mapper.ExamPlanMapper">

    <resultMap id="ExamPlanInfo" type="com.jf.exmpe.model.vo.ExamPlanInfoVO">
        <result column="KSBH" property="ksbh" jdbcType="VARCHAR"/>
        <result column="KSMC" property="ksmc" jdbcType="VARCHAR"/>
        <result column="KSKSRQ" property="ksksrq" jdbcType="VARCHAR"/>
        <result column="KSJSRQ" property="ksjsrq" jdbcType="VARCHAR"/>
        <result column="QYWSXC" property="qywsxc" jdbcType="VARCHAR"/>
        <result column="QYSFYZ" property="qysfyz" jdbcType="VARCHAR"/>
        <result column="QYZBFK" property="qyzbfk" jdbcType="VARCHAR"/>
        <result column="SJZT" property="sjzt" jdbcType="VARCHAR"/>
        <collection property="examSessionInfoVoList" ofType="com.jf.exmpe.model.vo.ExamSessionInfoVo" javaType="list">
            <result column="CCBH" property="ccbh" jdbcType="VARCHAR"/>
            <result column="CCMC" property="ccmc" jdbcType="VARCHAR"/>
            <result column="CCKSSJ" property="cckssj" jdbcType="VARCHAR"/>
            <result column="CCJSSJ" property="ccjssj" jdbcType="VARCHAR"/>
            <collection property="examSubjectInfoVOList" ofType="com.jf.exmpe.model.vo.ExamSubjectInfoVO" javaType="list">
                <result column="KMBH" property="kmbh" jdbcType="VARCHAR"/>
                <result column="KMMC" property="kmmc" jdbcType="VARCHAR"/>
                <result column="KMKSSJ" property="kmkssj" jdbcType="VARCHAR"/>
                <result column="KMJSSJ" property="kmjssj" jdbcType="VARCHAR"/>
            </collection>
        </collection>
    </resultMap>

    <select id="listExamPlanInfo" resultMap="ExamPlanInfo" >
        SELECT
            b.eid AS KSBH,
            b.NAME AS KSMC,
            b.start_time AS KSKSRQ,
            b.end_time AS KSJSRQ,
            c.es_num AS CCBH,
            c.NAME AS CCMC,
            c.start_time AS CCKSSJ,
            c.end_time AS CCJSSJ,
            d.subject_code AS KMBH,
            d.NAME AS KMMC,
            d.start_time AS KMKSSJ,
            d.end_time AS KMJSSJ,
            '0' AS QYWSXC,
            '0' AS QYSFYZ,
            '0' AS QYZBFK,
            b.STATUS AS SJZT
        FROM
            jf_expme_db.p_rel_orgenable AS a
            INNER JOIN jf_expme_db.p_examinfo AS b ON a.ex_id = b.eid
            INNER JOIN jf_expme_db.p_examsessioninfo AS c ON a.ex_id = c.ex_id
            INNER JOIN jf_expme_db.p_examsubjectinfo AS d ON d.es_num = c.es_num
            AND d.ex_id = c.ex_id
            AND a.org_id
            AND a.org_id = #{orgcode}
            INNER JOIN p_orginfo AS e ON e.org_code = a.org_id
            AND e.org_ident_code = #{orgIdenCode}
    </select>
	
</mapper>
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页