Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 11231 invoked from network); 12 Feb 2007 10:45:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Feb 2007 10:45:50 -0000 Received: (qmail 76504 invoked by uid 500); 12 Feb 2007 10:45:57 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 75937 invoked by uid 500); 12 Feb 2007 10:45:55 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 75926 invoked by uid 99); 12 Feb 2007 10:45:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Feb 2007 02:45:55 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of cecajina@hotmail.com designates 65.54.246.205 as permitted sender) Received: from [65.54.246.205] (HELO bay0-omc3-s5.bay0.hotmail.com) (65.54.246.205) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Feb 2007 02:45:43 -0800 Received: from hotmail.com ([64.4.17.76]) by bay0-omc3-s5.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Mon, 12 Feb 2007 02:45:22 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 12 Feb 2007 02:45:22 -0800 Message-ID: Received: from 189.192.222.123 by BAY111-DAV4.phx.gbl with DAV; Mon, 12 Feb 2007 10:45:19 +0000 X-Originating-IP: [189.192.222.123] X-Originating-Email: [cecajina@hotmail.com] X-Sender: cecajina@hotmail.com From: "Carlos Cajina" To: References: <299154da0702120137l62a2701blf2f2ac0acda35e0b@mail.gmail.com> Subject: Re: how to resolve same column/property name when reusing resultMap Date: Mon, 12 Feb 2007 04:45:18 -0600 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00E6_01C74E60.9892C150" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-OriginalArrivalTime: 12 Feb 2007 10:45:22.0373 (UTC) FILETIME=[E55EB750:01C74E92] X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------=_NextPart_000_00E6_01C74E60.9892C150 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Peng. I think you can try something like this: =20 = =20 Hope it helps. Regards, Carlos ----- Original Message -----=20 From: Peng Wang=20 To: user-java@ibatis.apache.org=20 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?=20 Thanks in advance, -Peng =20 =20 =20 ------=_NextPart_000_00E6_01C74E60.9892C150 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi Peng.
 
I think you can try something like=20 this:
 
<resultMap = id=3D"testPlanResult"=20 class=3D"TestPlan" groupBy=3D"id">
    <result = property=3D"id"=20 column=3D"id"/>
    <result property=3D"version" = column=3D"version"/>
    <result = property=3D"name"=20 column=3D"name"/>
    <result = property=3D"createdDate"=20 column=3D"createdDate" javaType=3D"java.util.Date" = />
   =20 <result property=3D"release" resultMap=3D" = Release.releaseResult"/> =20
</resultMap>
 
<resultMap = id=3D"releaseResult"=20 class=3D"Release" >
    <result property=3D"id"=20 column=3D"r_id
"/>
    = <result=20 property=3D"version" column=3D"version"/>
    = <result=20 property=3D"name" = column=3D"name"/>
 </resultMap>
 

<select = id=3D"findTestPlans"=20 resultMap=3D"testPlanResult">
    select=20
     tp.id as id,
     = tp.version=20 as version,
     tp.name as=20 name,
     tp.createdDate as=20 createdDate,
     r.id as r_id

    from TestPlan = tp left=20 join release r on tp.release =3D r.name
 =20 </select>
 
Hope it helps.
 
Regards,
 
Carlos
----- Original Message -----
From:=20 Peng = Wang
Sent: Monday, February 12, 2007 = 3:37=20 AM
Subject: how to resolve same=20 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=20 field named id. If we want to reuse the resultMap, what should we do = when we=20 create a query against these tables since both tables have the field = id, is=20 there any way in iBatis to identify which field should be mapped to = which=20 object?
 
Thanks in advance,
-Peng
 
<resultMap id=3D"testPlanResult" class=3D"TestPlan"=20 groupBy=3D"id">
    <result property=3D"id"=20 column=3D"id"/>
    <result = property=3D"version"=20 column=3D"version"/>
    <result = property=3D"name"=20 column=3D"name"/>
    <result = property=3D"createdDate"=20 column=3D"createdDate" javaType=3D"java.util.Date"=20 />
    <result property=3D"release" = resultMap=3D"=20 Release.releaseResult"/> 
</resultMap>
 
------=_NextPart_000_00E6_01C74E60.9892C150--