You don't have to - you can alias it in the SQL using the syntax
Carlos provided.

Larry


On 2/12/07, Peng Wang <[EMAIL PROTECTED]> wrote:
thanks, but what if the legacy database has the field name id and we cannot
change that?



On 2/12/07, Carlos Cajina <[EMAIL PROTECTED]> wrote:
>
>
> Hi Peng.
>
> I think you can try something like this:
>
> <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=" r_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 r_id
>     from TestPlan tp left join release r on tp.release = r.name
>   </select>
>
> Hope it helps.
>
> Regards,
>
> Carlos
>
>
> ----- Original Message -----
> From: Peng Wang
> To: [email protected]
> Sent: Monday, February 12, 2007 3:37 AM
> Subject: how to resolve same column/property name when reusing resultMap
>
>
> 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>


Reply via email to