mybatis一对多
一.课程包含课时
xml如下:
<resultMap id="culTrainCoursePO" type="com.thinkgem.jeesite.modules.train.entity.CulTrainCoursePO"> <id column="id" jdbcType="VARCHAR" property="id" /> <result column="course_name" jdbcType="VARCHAR" property="courseName" /> <result column="bel_project_id" jdbcType="VARCHAR" property="belProjectId" /> <collection property="culTrainLessonPOs" ofType="com.thinkgem.jeesite.modules.train.entity.CulTrainLessonPO"> <id property="id" column="lesson_id"/> <result property="courseId" column="course_id"/> <result property="lessonBatchNum" column="lesson_batch_num"/> </collection> </resultMap> <select id="selectCourseLessonById" parameterType="String" resultMap="culTrainCoursePO"> select c.*,l.id lesson_id,l.course_id,l.lesson_batch_num from cul_train_course c left join cul_train_lesson l on l.course_id = c.id where c.id = #{id} </select> <select id="selectCourseLesson" resultMap="culTrainCoursePO"> select c.*,l.id lesson_id,l.course_id,l.lesson_batch_num from cul_train_course c left join cul_train_lesson l on l.course_id = c.id </select>
参考来源:https://blog.csdn.net/qq_36791569/article/details/81517080