<resultMap id="menuQuery" type="com.wlpy.common.entity.Menu">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="parentId" jdbcType="VARCHAR" property="parentId" />
<result column="menuName" jdbcType="VARCHAR" property="menuName" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="perms" jdbcType="VARCHAR" property="perms" />
<collection property="menuList" select="lowMenu" column="id" ofType="com.wlpy.common.entity.Menu">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="parentId" jdbcType="VARCHAR" property="parentId" />
<result column="menuName" jdbcType="VARCHAR" property="menuName" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="perms" jdbcType="VARCHAR" property="perms" />
</collection>
</resultMap>
<select id="findAllMenu" parameterType="java.util.Map" resultMap="menuQuery">
SELECT
m.id,
m.parent_id AS parentId,
m.menu_name AS menuName,
m.url,
m.type,
m.perms
FROM
menu AS m
WHERE
m.available = 1
AND m.parent_id = 0
</select>
<select id="lowMenu" parameterType="java.util.Map" resultMap="menuQuery">
SELECT
m.id,
m.parent_id AS parentId,
m.menu_name AS menuName,
m.url,
m.type,
m.perms
FROM
menu AS m
WHERE
m.available = 1
AND m.parent_id = #{id} 父级ID
</select>
mybatis查询树形菜单sql效率低
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
5条回答 默认 最新
- CSDN专家-sinJack 2021-08-18 14:37关注
我看sql也不复杂,是查询慢吗,看下索引使用情况。
执行计划:explain sql语句本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 在现有系统基础上增加功能
- ¥15 远程桌面文档内容复制粘贴,格式会变化
- ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
- ¥15 这种微信登录授权 谁可以做啊
- ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
- ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
- ¥15 网络设备配置与管理这个该怎么弄
- ¥20 机器学习能否像多层线性模型一样处理嵌套数据
- ¥20 西门子S7-Graph,S7-300,梯形图
- ¥50 用易语言http 访问不了网页