• Mybatis夺标关联查询一对多实例


    <?xml version="1.0" encoding="UTF-8" ?>  
    <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"      
     "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
    <mapper namespace="com.hengyunsoft.mzhd.analysis.dao.DbxgxfxDao">

     <resultMap id="SingleSql1ToNResult" type="com.hengyunsoft.mzhd.analysis.data.FamilyInfo">
          <!-- id非常重要,用来区分记录 -->
          <id property="familyId" column="memberId"/>
          <result property="no" column="no"/>   
          <result property="nameOfApplicant" column="nameOfApplicant"/>
          <result property="certType" column="certType"/>
          <result property="numOfCert" column="numOfCert"/>
          <result property="apyDate" column="apyDate"/>
          <result property="salvageType" column="salvageType"/>
          <result property="busiType" column="busiType"/>
          <result property="blaType" column="blaType"/>      
          <result property="poorReson" column="poorreson"/>
          <result property="numOfFamily" column="numOfFamily"/>    
          <result property="apyReson" column="apyReson"/>
          <result property="passedNum" column="passed"/>
          <!-- 指定关联的集合属性的数据映射,ofType属性指定集合元素对应的数据类型 -->
          <collection property="persons" ofType="com.hengyunsoft.mzhd.analysis.data.Person">
            <id property="persionId" column="personId"/>
            <result property="no" column="familyno"/>
            <result property="workStatus" column="workStatus"/>
            <result property="health" column="health"/>
            <result property="disabilityDegree" column="disabilityDegree"/>
             <result property="workAblity" column="workAblity"/>       
            <result property="academicStatus" column="academicStatus"/>      
             <result property="degreeOfEdu" column="degreeOfEdu"/>
          </collection>
       </resultMap>
    <select id="getFamilyMes" resultMap="SingleSql1ToNResult">
        select p.*,m.* from persons p,members m where p.mid=m.memberId
    </select>
    </mapper>

    <!-- select p.no,p.poorreson,p.numOfFamilyp.,m.* from persons p,members m where p.familyno=m.no -->



     
     

  • 相关阅读:
    实习期收获(一)
    实习期上班两天感触
    做bbs论坛项目的收获(1)
    ios多线程
    C 预处理小结
    Xcode8 问题
    Unity3d收藏链接/ 小马哥视频
    H5(1)
    ios-loadView
    iOS开发UI篇—程序启动原理和UIApplication
  • 原文地址:https://www.cnblogs.com/sunfenqing/p/7285520.html
Copyright © 2020-2023  润新知