165-数据库使用链接查询时返回对象的扩展

我在crm项目中,即使使用了链接查询的时候,返回的resultType依然是使用的原本配置文件中的<ResultMap>标签,主要原因有两个
  1:我们的实体类的数据类型都是String类型。
  2:我们的链接查询只是返回的一个字段,但是在p2p项目,我们是将链接表的数据都返回了过来,放到了我们的扩展vo(Value Object)的属性中。

<!--投资记录与用户的关系:一对一-->
  <resultMap id="BidUserBaseResultMap" type="com.bjpowernode.p2p.model.vo.BidExtUser">
    <id column="id" jdbcType="INTEGER" property="id"/>
    <result column="loan_id" jdbcType="INTEGER" property="loanId"/>
    <result column="uid" jdbcType="INTEGER" property="uid"/>
    <result column="bid_money" jdbcType="DOUBLE" property="bidMoney"/>
    <result column="bid_time" jdbcType="TIMESTAMP" property="bidTime"/>
    <result column="bid_status" jdbcType="INTEGER" property="bidStatus"/>
    <association property="user" javaType="com.bjpowernode.p2p.model.user.User">
      <result column="phone" jdbcType="VARCHAR" property="phone"/>
      <result column="login_password" jdbcType="VARCHAR" property="loginPassword"/>
      <result column="name" jdbcType="VARCHAR" property="name"/>
      <result column="id_card" jdbcType="VARCHAR" property="idCard"/>
      <result column="add_time" jdbcType="TIMESTAMP" property="addTime"/>
      <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
      <result column="header_image" jdbcType="VARCHAR" property="headerImage"/>
    </association>
  </resultMap>
<!--投资记录与用户的关系:一对一-->
  <resultMap id="BidUserBaseResultMap" type="com.bjpowernode.p2p.model.vo.BidExtUser">
    <id column="id" jdbcType="INTEGER" property="id"/>
    <result column="loan_id" jdbcType="INTEGER" property="loanId"/>
    <result column="uid" jdbcType="INTEGER" property="uid"/>
    <result column="bid_money" jdbcType="DOUBLE" property="bidMoney"/>
    <result column="bid_time" jdbcType="TIMESTAMP" property="bidTime"/>
    <result column="bid_status" jdbcType="INTEGER" property="bidStatus"/>
    <association property="user" javaType="com.bjpowernode.p2p.model.user.User">
      <result column="phone" jdbcType="VARCHAR" property="phone"/>
      <result column="login_password" jdbcType="VARCHAR" property="loginPassword"/>
      <result column="name" jdbcType="VARCHAR" property="name"/>
      <result column="id_card" jdbcType="VARCHAR" property="idCard"/>
      <result column="add_time" jdbcType="TIMESTAMP" property="addTime"/>
      <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
      <result column="header_image" jdbcType="VARCHAR" property="headerImage"/>
    </association>
  </resultMap>
原文地址:https://www.cnblogs.com/pogusanqian/p/12828910.html