mybatis大家用得应该比较多也比较熟悉了,源码可能大家也都看了好几遍了,这里我说一下collection的实现细节,首先看一个简单的例子:
<select id="getRoleById" parameterType="string" resultMap="myResultMap">
select
*
from role
where id = #{roleId,jdbcType=VARCHAR}
</select>
<select id="getMenus" parameterType="string">
select
*
from menu
where id = #{roleId,jdbcType=VARCHAR}
</select>
<resultMap id="myResultMap" type="Role">
<id column="role_id" jdbcType="VARCHAR" property="roleId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<collection column="role_id" property="menus&#