Mybatis 一对多

Mybatis 一对多

<resultMap id="TeacherMap" type=fun.chenqi.TeacherEntity">
   <result property="id" column="id"/>
   <result property="headPic" column="head_pic"/>
   <result property="name" column="name"/>
   <collection property="teacherZylmEntityList"
               select="selectTeacherZylm"
           ofType="fun.chenqi.TeacherZylmEntity"
               column="id">
   </collection>
</resultMap>

<select id="selectTeacherZylm" parameterType="int" resultType="fun.chenqi..TeacherZylmEntity">
       select * from teacher_zylm where teacher_id = #{id}
   </select>

<select id="findTeacher" resultMap="TeacherMap" parameterType="map">
       select teacher.*
       from teacher
       where ...
         and ...
       order by ...
   </select>

发表评论