13、<resultMap>中 <collection>实现多级标签
一、需求:
SQL方式实现多级标签,类似于:

二、一级标签实体类声明:

三、二级标签实体类声明:

四、mybatis标签映射:
<resultMap>中的 <collection>来实现一对多映射关系:

<resultMap id="BaseResultMap" type="com.xxx.model.PageDemo" >
<id column="uuid" property="uuid" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="VARCHAR" />
<collection property="otherDemoList" ofType="com.xxx.model.OtherDemo">
<id column="uuid" jdbcType="VARCHAR" property="uuid" />
<result column="name" property="name" jdbcType="VARCHAR" />
</collection>
</resultMap>
浙公网安备 33010602011771号