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 -->

上一篇:c++ boost 汉字和模式串混用的例子


下一篇:Cockpit 容器&&kubernetes 管理可视化工具