<resultMap id="ClusterVoMap" type="com.gta.bigdata.model.ClusterVo" >
<result column="db_name" property="name" jdbcType="VARCHAR" />
<collection ofType="com.gta.bigdata.model.ClusterVo" property="children" >
<result column="org_name" property="name" jdbcType="VARCHAR" />
<collection ofType="com.gta.bigdata.model.DBNameVo" property="children" >
<result column="user_name" property="name" jdbcType="VARCHAR" />
</collection>
</collection>
</resultMap>
<select id="selectDataWithHierarchy" resultMap="ClusterVoMap" parameterType="java.lang.Integer" >
SELECT
t4. NAME user_name,
t3. NAME org_name,
t2. NAME db_name
FROM
testtable t1
JOIN TestDBname t2 ON t1.dbid = t2.dbid
JOIN TestGrade t3 ON t1.shoolID = t3.grade
JOIN TestUser t4 ON t1.userID = t4.userid
where t1.dbid = #{dbID,jdbcType=INTEGER}
</select>
数据结构: