zoukankan      html  css  js  c++  java
  • 一对多的三种方式和多对一

    <!-- 对象级联 -->
        <resultMap type="Emp" id="emplist1">
            <id property="empno" column="EMPNO"/>
            <result property="ename" column="ENAME"/>
            <result property="job" column="JOB"/>
            <result property="mgr" column="MGR"/>
            <result property="hiredate" column="HIREDATE"/>
            <result property="sal" column="SAL"/>
            <result property="comm" column="COMM"/>
            <result property="deptno" column="DEPTNO"/>
            <result property="sex" column="SEX"/>
            <result property="dept.dno" column="DNO"/>
            <result property="dept.dname" column="DNAME"/>
            <result property="dept.loc" column="LOC"/>
        </resultMap>
    <!-- 关联 -->
        <resultMap type="Emp" id="emplist2">
            <id property="empno" column="EMPNO"/>
            <result property="ename" column="ENAME"/>
            <result property="job" column="JOB"/>
            <result property="mgr" column="MGR"/>
            <result property="hiredate" column="HIREDATE"/>
            <result property="sal" column="SAL"/>
            <result property="comm" column="COMM"/>
            <result property="deptno" column="DEPTNO"/>
            <result property="sex" column="SEX"/>
            <association property="dept" resultMap="deptlist"></association>
        </resultMap>
        <resultMap type="Dept" id="deptlist">
            <result property="dno" column="DNO"/>
            <result property="dname" column="DNAME"/>
            <result property="loc" column="LOC"/>
        </resultMap> 
    <!-- 关联查询 -->·
        <!-- <resultMap type="Emp" id="emplist3">
            <association property="dept" column="DEPTNO" select="mapper.DeptMapper.selectDept"></association>
        </resultMap>
        <select id="selectAllEmp" resultMap="emplist3">
            select * from p_emp e 
        </select> -->

    多对一

    <resultMap type="Dept" id="deptSelect">
            <id    property="dno" column="dno"/>
            <collection property="emp" column="dno" select="mapper.EmpMapper.selectOneEmp"/>
        </resultMap>
        <select id="selectDept" parameterType="Integer" resultMap="deptSelect">
            select * from p_dept d where d.dno=#{dno}
        </select>
  • 相关阅读:
    Rigidbody和Collider
    Unity官方实例教程 Roll-a-Ball
    unity还原three之旋转
    unity还原three——顶点,三角面,uv
    unity还原three导出的json——基本模型,位移,旋转,缩放
    【struts2基础】配置详解
    【深入Struts2】获取ServletAPI的三种方式
    JDBC事务与事务隔离级别详解
    【GOF23设计模式】--工厂模式
    【GOF23设计模式】--单例模式
  • 原文地址:https://www.cnblogs.com/donghb/p/7580179.html
Copyright © 2011-2022 走看看