结果集:
<resultMap id="groupMap" type="HashMap">
<result column="code" jdbcType="VARCHAR" property="code"/>
<collection property="roles" column="code" select="listChild"/>
</resultMap>sql:
<select id="listAndGroupByCode" resultMap="groupMap">
SELECT code FROM bee_role
where 1=1
<if test="code !=null and code !=''">
and code = #{code}
</if>
GROUP BY code
</select> <select id="listChild" resultType="map">
SELECT id,code,name
FROM bee_role
where 1=1
and code = #{code}
</select>查询结果:

版权声明:本文为weixin_38384296原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。