ibatis resultMap result中的resultMap问题

今天从mybatis迁移一个mapper到ibatis(2.0)中,发现有一个标签(association),ibatis不支持。

mybatis中的代码:

JavaBean

@Data
public class InstitutionExpert extends BaseBusEntity {
   private String id;
   private String createBy;
   private Date createDate;
   private String updateBy;
   private Date updateDate;
   private Integer deleteFlag;
   private Expert expert;
}
 
mapper.xml:简写
<resultMap type="institutionExpert" id="institutionExpertResultMap">
   <id property="id" column="ID" />
   <result property="createBy" column="C_CREATE_BY" />
   <result property="createDate" column="C_CREATE_DATE" />
   <result property="updateBy" column="C_UPDATE_BY" />
   <result property="updateDate" column="C_UPDATE_DATE" />
   <result property="deleteFlag" column="C_DELETE_FLAG" />
   <association property="expert" javaType="expert" column="C_EXPERT_ID">
      <id property="id" column="C_EXPERT_ID" />
   </association> 
</resultMap

<select id="listInstitutionExpertByPage" resultMap="institutionExpertResultMap">
   SELECT <include refid="allColumnSql"/>
   FROM institution_expert o
   left join expert e on o.C_EXPERT_ID = e.ID
   WHERE  o.C_EXPERT_ID is NOT null <include refid="searchConditionSql"/>
</select>

由于ibatis(2.0)不支持(association)
ibatis代码为(javaBean不变):
<resultMap class="institutionExpert" id="institutionExpertBaseResultMap">
   <result property="id" column="ID" />
   <result property="createBy" column="C_CREATE_BY" />
   <result property="createDate" column="C_CREATE_DATE" />
   <result property="updateBy" column="C_UPDATE_BY" />
   <result property="updateDate" column="C_UPDATE_DATE" />
   <result property="deleteFlag" column="C_DELETE_FLAG" />
   <result property="expert" resultMap="namespace.expertBaseResultMap" column="C_EXPERT_ID"/>
</resultMap>
<resultMap id="expertBaseResultMap" class="expert">
   <result property="id" column="ID" />
</resultMap>
变更了resultMap中result,在result中加入resultMap(这个resultMap要新增)。
注意情况:在mybatis中,如果resultMap中有一列在查询的表中不存在,不会报错,而在ibatis中,则会报错。


 
 
 
 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值