<resultMap id="ChartResultMap" type="com.qif.dsa.ucenter.planinfo.entity.ChartDate">
        <id column="time" jdbcType="VARCHAR" property="time"/>
        <collection property="planChartList"   javaType="java.util.List"
                    column="time" ofType="com.qif.dsa.ucenter.planinfo.entity.PlanChart" >
            <id column="time" jdbcType="VARCHAR" property="time" />

下面的i-State 是数据库里的字段, iState 则是展示到页面的字段
<result column="i_State" jdbcType="VARCHAR" property="iState" /> <result column="stateCount" jdbcType="INTEGER" property="stateCount" /> </collection> </resultMap>


以上写法用于一对多select..... leftjoin .....

 

 

 

  <resultMap id="BigTypeResultMap" type="com.qif.dsa.ucenter.bigtype.entity.BigType">
        <id column="BigTypeId" jdbcType="INTEGER" property="bigTypeId" />
        <result column="vc_Name" jdbcType="VARCHAR" property="vcName" />

      这里的BigTypeId 作为外键 
    querySmallTypeByBigId方法是另外一个dao层里面通过外键查到的数据 一次返回
<collection property="smallTypeList" column="BigTypeId" select="com.qif.dsa.ucenter.smallType.dao.SmallTypeDao.querySmallTypeByBigId"/> </resultMap>




以上写法用于一对多 select.....(包含外键)
原理:    一条不关联的sql 里面包含外键 
         当返回值为带有 select  的collection时,自动从别的表调用查询语句 返回整体结果                   

 

 

<resultMap id="HazardResultMap" type="com.qif.dsa.ucenter.hazardinfo.entity.HazardInfo">
        <id column="HazardID" jdbcType="INTEGER" property="hazardId" />
        <result column="RcuID" jdbcType="INTEGER" property="rcuId" />
        <result column="vc_HazardContent" jdbcType="VARCHAR" property="vcHazardContent" />
        <result column="vc_FillPeople" jdbcType="VARCHAR" property="vcFillPeople" />
        <association property="rcuInfo" javaType="com.qif.dsa.ucenter.rcuinfo.entity.RcuInfo" columnPrefix="rcu_">
            <id property="rcuId" jdbcType="INTEGER" column="RcuID"/>
            <result property="orgId" jdbcType="INTEGER" column="OrgID"/>
            <result property="vcName" jdbcType="VARCHAR"  column="vcName"/>
        </association>
    </resultMap>


以上写法用于一对一  select..... innerjoin   .....  
 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2021-08-08
  • 2021-09-24
  • 2021-08-09
  • 2021-09-16
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2021-07-25
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2021-04-24
相关资源
相似解决方案