mybatis递归查询
Posted Superb1995
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis递归查询相关的知识,希望对你有一定的参考价值。
<!--mybatis递归查询-->
<resultMap id="recursionMenuMap" type="AgentMenu" extends="BaseResultMap">
<collection property="children" ofType="AgentMenu" column="{agentMenuId=agent_menu_id,agentId=agent_id}" select="findMenuByParentId"/>
</resultMap>
<select id="getAgentMenuByAgentId" resultMap="recursionMenuMap">
select * from agent_menu am inner join (select id,agent_id,agent_menu_id from agent_has_menu where agent_id=#{0}) ahm on am.agent_menu_id=ahm.agent_menu_id and closed=0
and super_id is NULL order by agent_menu_level
</select>
<select id="findMenuByParentId" resultMap="recursionMenuMap">
SELECT * FROM (select * from agent_menu WHERE super_id = #{agentMenuId}) am inner join (select agent_menu_id,agent_id from agent_has_menu where agent_id=#{agentId}) ahm on am.agent_menu_id=ahm.agent_menu_id and closed=0
</select>
以上是关于mybatis递归查询的主要内容,如果未能解决你的问题,请参考以下文章