在MyBatis中,可以使用
<resultMap id="userMap" type="User">
<id column="id" property="id"/>
<result column="username" property="username"/>
<collection property="posts" ofType="Post">
<id column="post_id" property="postId"/>
<result column="post_title" property="title"/>
<result column="post_content" property="content"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<association property="author" column="user_id"
select="getUserById"/>
<orderBy property="createTime" order="DESC"/>
</collection>
</resultMap>
在上面的示例中,