• 多对多查询


    先决条件一:多对多需要一种中间表建立连接关系;
    先决条件二:多对多关系是由两个一对多关系组成的,一对多可以也可以用两种方式实现;

    <resultMap type="TUser" id="userRoleInfo" extends="BaseResultMap">
            <collection property="roles" ofType="TRole" columnPrefix="role_">
                <result column="id" property="id" />
                <result column="Name" property="roleName" />
                <result column="note" property="note" />
            </collection>
        </resultMap>
        
        
        <select id="selectUserRole" resultMap="userRoleInfo">
            select a.id, 
                  a.user_name,
                  a.real_name,
                  a.sex,
                  a.mobile,
                  a.note,
                  b.role_id,
                  c.role_name,
                  c.note role_note
            from t_user a,
                 t_user_role b,
                 t_role c
            where a.id = b.user_id AND 
                  b.role_id = c.id
         </select>    
  • 相关阅读:
    selenium + python网页自动化测试环境搭建
    工作总结
    脚本测试总结
    一些知识
    反相器
    递归算法设计
    什么是递归
    CSS3弹性盒模型布局模块
    小方法
    第24章 最佳实践
  • 原文地址:https://www.cnblogs.com/qin1993/p/12017509.html
Copyright © 2020-2023  润新知