<resultMapid="blogResult"type="Blog"> <collectionproperty="posts"javaType="ArrayList"column="id"ofType="Post"select="selectPostsForBlog"/></resultMap><selectid="selectBlog"resultMap="blogResult"> SELECT * FROM BLOG WHERE ID = #{id}</select><selectid="selectPostsForBlog"resultType="Post"> SELECT * FROM POST WHERE BLOG_ID = #{id}</select>
<select id="selectBlog" resultMap="blogResult">select B.id as blog_id, B.title as blog_title, B.author_id as blog_author_id, P.id as post_id, P.subject as post_subject, P.body as post_body,from Blog Bleft outer join Post P on B.id = P.blog_idwhere B.id = #{id}</select>