zoukankan      html  css  js  c++  java
  • Mybatis 使用 SQL 递归获取单表中的树结构

    • xml 代码
    <resultMap type="xxx.xxx.xxx.xxx.实体类" id="xxxListTree">
            <result column="id" property="id" javaType="java.lang.Long" />
            <result column="xxx_name" property="xxxName" javaType="java.lang.String" />
            <result column="parent_id" property="parentId" javaType="java.lang.Long" />
            <result column="create_user" property="createUser" javaType="java.lang.Long" />
    <!--        <collection column="{id=id,currentUserId=create_user}" property="xxxxListDtoList" ofType="com.cloud.datasynergy.model.xxxxListDto" javaType="java.util.ArrayList" select="selectXxxxXXXrenById"/>-->
            <collection autoMapping="true" column="{id=id,currentUserId=create_user}" javaType="ArrayList" ofType="xxx.xxx.xxx.xxx.实体类" property="实体类里面的list集合,用于存储子节点数据" select="selectXxxxXxxxrenById">
            </collection>
        </resultMap>
    
    
    <select id="selectXxxxList" resultMap="xxxListTree">
            select * from t_Xxxx_list where parent_id = #{id} and create_user = #{currentUserId} and is_del = 0
        </select>
    
    
    <select id="selectXxxxXXXrenById" resultMap="xxxListTree">
            select * from t_Xxxx_listwhere parent_id = #{id} and create_user = #{currentUserId} and is_del = 0
        </select>
    
    • 如何在递归是传递多个参数
    column="{id=id,currentUserId=create_user}"
    
    > =左边代表 dao or mapper 中的参数,=右边代表数据库表中的字段
  • 相关阅读:
    为 Jenkins 配置 .NET 持续集成环境
    树莓派连接GPS模块
    杂记
    大型网站架构系列:电商网站架构案例
    我的心博客。
    555555555555111
    powershell 环境变量只有当前会话起作用问题
    powershell 下独立silent 安装 浏览器问题
    python编码格式
    scss教程推荐
  • 原文地址:https://www.cnblogs.com/gaofangye/p/12575885.html
Copyright © 2011-2022 走看看