one to many relation using mybatis or ibatis

我与影子孤独终老i 提交于 2019-12-01 00:34:30
cporte

As shown in the manual, you have to write a more complex query and change the mapper.

The request will be something like that :

<select id="selectPosts" resultType="com.mycom.myproject.bean.postBean">  
    select id, post_name, file_id, file_name as postName from post left outer join files
</select>

And your result map :

<resultMap id="detailedPostResultMap" type="Blog">
  <result property="id" column="id"/>
  <result property="name" column="post_name"/>
  <collection property=filesAttachment" ofType="FileAttachment">
     <id property="fileId" column="file_id"/>
     <result property="fileName" column="file_name"/>
  </collection>
</resultMap>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!