ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peng Wang" <wpc...@gmail.com>
Subject how to resolve same column/property name when reusing resultMap
Date Mon, 12 Feb 2007 09:37:29 GMT
Hi All,

I am wondering how we can resolve the following naming issues.
Suppose we have two objects TestPlan and Release, both of them have a field
named id. If we want to reuse the resultMap, what should we do when we
create a query against these tables since both tables have the field id, is
there any way in iBatis to identify which field should be mapped to which
object?

Thanks in advance,
-Peng

<resultMap id="testPlanResult" class="TestPlan" groupBy="id">
    <result property="id" column="id"/>
    <result property="version" column="version"/>
    <result property="name" column="name"/>
    <result property="createdDate" column="createdDate" javaType="
java.util.Date" />
    <result property="release" resultMap="Release.releaseResult"/>
</resultMap>

 <resultMap id="releaseResult" class="Release" >
    <result property="id" column="id"/>
    <result property="version" column="version"/>
    <result property="name" column="name"/>
 </resultMap>


<select id="findTestPlans" resultMap="testPlanResult">
    select
     tp.id as id,
     tp.version as version,
     tp.name as name,
     tp.createdDate as createdDate,
     r.id as ?????
    from TestPlan tp left join release r on tp.release = r.name
  </select>

Mime
View raw message