标签:res oci nbsp one 多对一 iat collect job selectall
<!-- 对象级联 --> <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>
标签:res oci nbsp one 多对一 iat collect job selectall
原文地址:http://www.cnblogs.com/donghb/p/7580179.html