mybatis查询返回多个List对象,List<String>和一个实体类对象的List

实体类:

@Data
public class EvaluateRequest {
    private String id;
     private List<String> clazzIdList = new ArrayList<>();
    private List<CourseTypeView> courseList = new ArrayList<CourseTypeView>();
    private List<String> examIdList = new ArrayList<>();
}
@Data
public class CourseTypeView {
    private String id;
    private String name;
    List<CourseExperimentView> courseList;
}
@Data
public class CourseExperimentView {
    private String courseId;
    private String courseName;
    List<ExperimentView> experimentList;
}

xml:

 <resultMap id="evaluateRequestResult" type="com.model.request.exercises.EvaluateRequest">
        <result property="id" column="id"></result>
        <result property="name" column="name"></result>
        <result property="flag" column="flag"></result>
        <collection property="courseList" ofType="com.model.response.CourseTypeView">
            <result property="id" column="type_id"></result>
            <collection property="courseList" ofType="com.model.response.CourseExperimentView">
                <result property="courseId" column="course_id"></result>
                <result property="courseName" column="course_name"></result>
            </collection>
        </collection>
        <collection property="clazzIdList" resultMap="clazzIdMap" />
        <collection property="examIdList" resultMap="examIdMap" />
    </resultMap>

    <resultMap id="clazzIdMap" type="String">
        <result column="clazz_id" />
    </resultMap>

    <resultMap id="examIdMap" type="String">
        <result column="exam_id" />
    </resultMap>
    
    <select id="selectOneById" parameterType="String" resultMap="evaluateRequestResult">
        select distinct e.id, e.name, e.flag, becr.type_id, becr.course_id, becr.course_name, ecr.clazz_id, eer.exam_id
        from bde_evaluate e
        left join bde_evaluate_clazz_rel ecr on e.id = ecr.evaluate_id
        left join bde_evaluate_course_rel becr on e.id = becr.evaluate_id
        left join bde_evaluate_exam_rel eer on e.id = eer.evaluate_id
        where e.id = #{id}
    </select>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值