1.表格结构图(需求:获取登录账号的所有父角色。第一张表是角色表,第二张表是账号表)
xml代码
<resultMap type="com.lmt.softwareledger.entity.base.TRole" id="getRoleParentMap"> <id column="id" property="id"></id> <result column="roleName" property="roleName"/> <result column="createAccountID" property="createAccountID"/> <result column="roleType" property="roleType"/> <collection property="parentRole" select="getParentRole" column="{id=roleID}"> </collection> </resultMap> <select id="getParentRole" resultMap="getRoleParentMap"> SELECT a.id,roleName,b.roleID,createAccountID,roleType from t_role a INNER JOIN t_account b on a.createAccountID=b.ID where a.id=#{id} </select>
实体类代码