IbatiS关联字段映射

IbatiS的一个小功能。

在编写resultMap的时候,如果自己定义了一个数据库中并不对应的字段,比如是关联其他表的字段。则可以这样实现:

<result property="type" column="type_id" select="Asset.getTypeById" />

然后编写对应的select即可:

  <select id="getTypeById"  parameterClass="java.lang.String" resultClass="java.lang.String">

<![CDATA[

select

name

from tb_asset_type

where type_id = '$String$'

]]>

</select> 

这样,这个select将以column字段作为参数进行查询,返回结果映射到到类的相应属性上去。 

posted @ 2010-03-22 08:43  echozhjun  阅读(339)  评论(0编辑  收藏  举报