`
kisaii
  • 浏览: 7275 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

mybatis的collection用法,表示has-many

阅读更多
前提:Teacher(integer id,String name,List<Student> students);

<resultMap>
    <collection property="students"       resultMap="StudentMapper.StudentResultMap" />
</resultMap>

<!-- StudengResultMap 在 StudentMapper 包中 -->

<select id="findTeacherById" parameterType="int" resultMap="TeacherResultMap" >
    select  tt.id as t_id,
   tt.name as t_name,
   ts.id as s_id,
   ts.name as s_name,
   ts.supervisor_id as s_supervisor_id
    from    t_teacher tt left outer join t_student ts
    on    tt.id = ts.supervisor_id
    where   tt.id=#{id}
</select>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics