zoukankan      html  css  js  c++  java
  • 级联查询

    <resultMap id="BaseResultMap" type="com.beta.cas.model.AuthModel">
            <id column="id" property="id" />
            <result column="name" property="name" />
            <result column="status" property="status" />
            <result column="levels" property="levels" />
            <result column="parent_id" property="parentId" />
            <result column="url" property="url" />
            <result column="show" property="show" />
            <result column="icon" property="icon" />
            <result column="sort" property="sort" />
            <result column="permission" property="permission" />
            <result column="creator_id" property="creatorId" />
            <result column="creator" property="creator" />
            <result column="create_time" property="createTime" />
            <result column="modify_id" property="modifyId" />
            <result column="modify_by" property="modifyBy" />
            <result column="modify_time" property="modifyTime" />
            <result column="app_id" property="appId" />
            <collection property="children" ofType="com.beta.cas.model.AuthModel" select="selectByParentId" column="id"></collection>
        </resultMap>
        <select id="findById" resultMap="BaseResultMap" parameterType="long">
            select * from auth where id = #{id}
        </select>
        <select id="findByAppId" resultMap="BaseResultMap">
            select * from auth where app_id = #{appId} and levels = #{levels} order by id
        </select>
        <select id="selectByParentId" resultMap="BaseResultMap">
            select am.* from auth am  where am.parent_id=#{parentId}
        </select>

    如果返回一个对象,可以增加

    <association property="parent" javaType="com.beta.cas.model.AuthModel" select="findById" column="parent_id"></association>

    如果返回一个集合,则必须去掉

    否则出现高度递归情况

  • 相关阅读:
    作业3
    学习进度
    作业2
    介绍自己,并介绍github注册过程和初步使用
    mysql显示中文乱码问题解决
    数学能力测试
    C++ Primer总结
    shell脚本
    完全二叉树
    test命令的测试功能
  • 原文地址:https://www.cnblogs.com/yangfei-beijing/p/8822620.html
Copyright © 2011-2022 走看看