码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis递归查询

时间:2018-11-08 18:34:09      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:查询   prope   bat   menu   col   from   property   tis   rom   

<!--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递归查询

标签:查询   prope   bat   menu   col   from   property   tis   rom   

原文地址:https://www.cnblogs.com/Superb1995/p/9930087.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!