1.表格結構圖(需求:獲取登陸帳號的全部父角色。第一張表是角色表,第二張表是帳號表)spa
xml代碼code
<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>
實體類代碼xml