You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jasmin Mehta <Ja...@nexweb.org> on 2009/03/27 16:51:58 UTC
How to define alias in
Hi,
With below code how do I get correct value for dependent first name and
dependent last name? Right now as both qol_customer and qol_dependet has
same field name for FIRST_NAME and LAST_NAME, I am getting qol_customer's
FIRST_NAME and LAST_NAME populated in
customerDependentVo.depFirstName
customerDependentVo.depLastName
properties. Is there any way I can define in <resultMap> that such field
is coming from such and such table?
Thanks
Jasmin
<typeAlias alias="customerVo"
type="org.nexweb.qol.gcc.model.CustomerVO"/>
<resultMap id="customerRS" class="customerVo">
<result property="custStatus" column="CUST_STATUS"/>
<result property="firstName" column="FIRST_NAME"/>
<result property="middleName" column="MIDDLE_NAME"/>
<result property="lastName" column="LAST_NAME"/>
<result property="customerDependentVo.depFirstName"
column="FIRST_NAME"/>
<result property="customerDependentVo.depLastName"
column="LAST_NAME"/>
</resultMap>
<select id="getListOfCustomersBySSNMask" resultMap="customerRS"
parameterClass="java.util.Map">
SELECT
cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
dep.first_name, dep.last_name
FROM
qol_customer cu,
qol_dependent dep
WHERE
AND cu.cust_id = dep.cust_id (+)
</select>
public class CustomerVO implements Serializable {
private Integer custId;
private Integer custStatus;
private String firstName;
private String middleName;
private String lastName;
private CustomerDependentVO customerDependentVo;
... all the accessor methods
}
public class CustomerDependentVO implements Serializable
{
private Integer custId;
private String depFirstName;
private String depLastName;
private String depMiddleName;
... all the accessors
}
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
******************************************************************************
Re: How to define alias in
Posted by Larry Meadors <la...@gmail.com>.
You can also poke yourself in the eye with a sharp stick, but in
either case it's a bad idea, imo. :-P
Larry
On Fri, Mar 27, 2009 at 10:10 AM, Brandon Goodin
<br...@gmail.com> wrote:
> You can specify the columnIndex (yuck).
> <result property="customerDependentVo.depFirstName"
> columnIndex="..."/>
> <result
> property="customerDependentVo.depLastName" columnIndex ="..."/>
>
> Brandon Goodin
> Silver Mind Software
> http://www.silvermindsoftware.com
> bgoodin@silvermindsoftware.com
> 615-306-3652
> http://www.linkedin.com/in/bgoodin
>
>
> On Fri, Mar 27, 2009 at 11:03 AM, Jasmin Mehta <Ja...@nexweb.org>
> wrote:
>>
>> I can not change the column names of table QOL_DEPENDENT
>>
>> from FIRST_NAME to DEP_FIRST_NAME
>>
>> It has to be the same.
>>
>>
>> From: Brandon Goodin <br...@gmail.com>
>> To:
>> user-java@ibatis.apache.org
>> Date: 03/27/2009 11:59 AM
>> Subject: Re: How to define alias in <resultMap>
>> ________________________________
>>
>> <typeAlias alias="customerVo"
>> type="org.nexweb.qol.gcc.model.CustomerVO"/>
>>
>> <resultMap id="customerRS" class="customerVo">
>> <result property="custStatus" column="CUST_STATUS"/>
>> <result property="firstName" column="FIRST_NAME"/>
>> <result property="middleName" column="MIDDLE_NAME"/>
>> <result property="lastName" column="LAST_NAME"/>
>> <result property="customerDependentVo.depFirstName"
>> column="DEP_FIRST_NAME"/>
>> <result property="customerDependentVo.depLastName"
>> column="DEP_LAST_NAME"/>
>> </resultMap>
>>
>>
>> <select id="getListOfCustomersBySSNMask" resultMap="customerRS"
>> parameterClass="java.util.Map">
>> SELECT
>> cs.cust_status, cu.first_name, cu.middle_name,
>> cu.last_name,
>> dep.first_name as dep_first_name, dep.last_name as
>> dep_last_name
>> FROM
>> qol_customer cu,
>> qol_dependent dep
>> WHERE
>> AND cu.cust_id = dep.cust_id (+)
>> </select>
>>
>> public class CustomerVO implements Serializable {
>> private Integer custId;
>> private Integer custStatus;
>> private String firstName;
>> private String middleName;
>> private String lastName;
>>
>> private CustomerDependentVO customerDependentVo;
>> ... all the accessor methods
>>
>> }
>>
>> public class CustomerDependentVO implements Serializable
>> {
>> private Integer custId;
>> private String depFirstName;
>> private String depLastName;
>> private String depMiddleName;
>>
>> ... all the accessors
>> }
>>
>>
>> ******************************************************************************
>> This email and any files transmitted with it are intended solely for
>> the use of the individual or agency to whom they are addressed.
>> If you have received this email in error please notify the Navy
>> Exchange Service Command e-mail administrator. This footnote
>> also confirms that this email message has been scanned for the
>> presence of computer viruses.
>>
>> Thank You!
>>
>> ******************************************************************************
>
Re: How to define alias in
Posted by Brandon Goodin <br...@gmail.com>.
No problem. I'm glad it worked out for you.
Brandon
On Fri, Mar 27, 2009 at 11:58 AM, Jasmin Mehta <Ja...@nexweb.org>wrote:
>
> alias in SQL will work, Sorry I overlooked the SQL change earlier in first
> posting. And just saw the table column name in resultMap. I apologies.
>
> Thanks for all your help.
>
>
> From: Brandon Goodin <br...@gmail.com>
> To: user-java@ibatis.apache.org
> Date: 03/27/2009 12:29 PM
> Subject: Re: How to define alias in <resultMap>
>
> ------------------------------
>
>
> You know rethinking your statement. It makes no sense. You just showed us
> the SQL. You can add an alias in the SQL. It does *not* change your table.
> It only changes the column name in the result. Then you just map it in the
> resultMap like we originally said.
>
> Brandon
>
>
> On Fri, Mar 27, 2009 at 11:10 AM, Brandon Goodin <*
> brandon.goodin@gmail.com* <br...@gmail.com>> wrote:
> You can specify the columnIndex (yuck).
>
> <result property="customerDependentVo.depFirstName"
> columnIndex="..."/>
> <result
> property="customerDependentVo.depLastName" columnIndex ="..."/>
>
> Brandon Goodin
> Silver Mind Software
> *http://www.silvermindsoftware.com* <http://www.silvermindsoftware.com>
> *bgoodin@silvermindsoftware.com* <bg...@silvermindsoftware.com>
> 615-306-3652
> *http://www.linkedin.com/in/bgoodin* <http://www.linkedin.com/in/bgoodin>
>
>
>
> On Fri, Mar 27, 2009 at 11:03 AM, Jasmin Mehta <*J...@nexweb.org>>
> wrote:
>
> I can not change the column names of table QOL_DEPENDENT
>
> from FIRST_NAME to DEP_FIRST_NAME
>
> It has to be the same.
>
>
> From: Brandon Goodin <*b...@gmail.com>
> > To: *user-java@ibatis.apache.org* <us...@ibatis.apache.org> Date: 03/27/2009
> 11:59 AM Subject: Re: How to define alias in <resultMap>
> ------------------------------
>
>
>
> <typeAlias alias="customerVo"
> type="org.nexweb.qol.gcc.model.CustomerVO"/>
>
> <resultMap id="customerRS" class="customerVo">
> <result property="custStatus" column="CUST_STATUS"/>
> <result property="firstName" column="FIRST_NAME"/>
> <result property="middleName" column="MIDDLE_NAME"/>
> <result property="lastName" column="LAST_NAME"/>
> <result property="customerDependentVo.depFirstName"
> column="DEP_FIRST_NAME"/>
> <result property="customerDependentVo.depLastName"
> column="DEP_LAST_NAME"/>
> </resultMap>
>
>
> <select id="getListOfCustomersBySSNMask" resultMap="customerRS"
> parameterClass="java.util.Map">
> SELECT
> cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
>
> dep.first_name as dep_first_name, dep.last_name as
> dep_last_name
> FROM
> qol_customer cu,
> qol_dependent dep
> WHERE
> AND cu.cust_id = dep.cust_id (+)
> </select>
>
> public class CustomerVO implements Serializable {
> private Integer custId;
> private Integer custStatus;
> private String firstName;
> private String middleName;
> private String lastName;
>
> private CustomerDependentVO customerDependentVo;
> ... all the accessor methods
>
> }
>
> public class CustomerDependentVO implements Serializable
> {
> private Integer custId;
> private String depFirstName;
> private String depLastName;
> private String depMiddleName;
>
> ... all the accessors
> }
>
>
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!
> *
> ******************************************************************************
> *
>
>
Re: How to define alias in
Posted by Jasmin Mehta <Ja...@nexweb.org>.
alias in SQL will work, Sorry I overlooked the SQL change earlier in first
posting. And just saw the table column name in resultMap. I apologies.
Thanks for all your help.
From:
Brandon Goodin <br...@gmail.com>
To:
user-java@ibatis.apache.org
Date:
03/27/2009 12:29 PM
Subject:
Re: How to define alias in <resultMap>
You know rethinking your statement. It makes no sense. You just showed us
the SQL. You can add an alias in the SQL. It does *not* change your table.
It only changes the column name in the result. Then you just map it in the
resultMap like we originally said.
Brandon
On Fri, Mar 27, 2009 at 11:10 AM, Brandon Goodin <brandon.goodin@gmail.com
> wrote:
You can specify the columnIndex (yuck).
<result property="customerDependentVo.depFirstName"
columnIndex="..."/>
<result
property="customerDependentVo.depLastName" columnIndex ="..."/>
Brandon Goodin
Silver Mind Software
http://www.silvermindsoftware.com
bgoodin@silvermindsoftware.com
615-306-3652
http://www.linkedin.com/in/bgoodin
On Fri, Mar 27, 2009 at 11:03 AM, Jasmin Mehta <Ja...@nexweb.org>
wrote:
I can not change the column names of table QOL_DEPENDENT
from FIRST_NAME to DEP_FIRST_NAME
It has to be the same.
From:
Brandon Goodin <br...@gmail.com>
To:
user-java@ibatis.apache.org
Date:
03/27/2009 11:59 AM
Subject:
Re: How to define alias in <resultMap>
<typeAlias alias="customerVo"
type="org.nexweb.qol.gcc.model.CustomerVO"/>
<resultMap id="customerRS" class="customerVo">
<result property="custStatus" column="CUST_STATUS"/>
<result property="firstName" column="FIRST_NAME"/>
<result property="middleName" column="MIDDLE_NAME"/>
<result property="lastName" column="LAST_NAME"/>
<result property="customerDependentVo.depFirstName"
column="DEP_FIRST_NAME"/>
<result property="customerDependentVo.depLastName"
column="DEP_LAST_NAME"/>
</resultMap>
<select id="getListOfCustomersBySSNMask" resultMap="customerRS"
parameterClass="java.util.Map">
SELECT
cs.cust_status, cu.first_name, cu.middle_name,
cu.last_name,
dep.first_name as dep_first_name, dep.last_name as
dep_last_name
FROM
qol_customer cu,
qol_dependent dep
WHERE
AND cu.cust_id = dep.cust_id (+)
</select>
public class CustomerVO implements Serializable {
private Integer custId;
private Integer custStatus;
private String firstName;
private String middleName;
private String lastName;
private CustomerDependentVO customerDependentVo;
... all the accessor methods
}
public class CustomerDependentVO implements Serializable
{
private Integer custId;
private String depFirstName;
private String depLastName;
private String depMiddleName;
... all the accessors
}
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
******************************************************************************
Re: How to define alias in
Posted by Brandon Goodin <br...@gmail.com>.
You know rethinking your statement. It makes no sense. You just showed us
the SQL. You can add an alias in the SQL. It does *not* change your table.
It only changes the column name in the result. Then you just map it in the
resultMap like we originally said.
Brandon
On Fri, Mar 27, 2009 at 11:10 AM, Brandon Goodin
<br...@gmail.com>wrote:
> You can specify the columnIndex (yuck).
>
> <result property="customerDependentVo.depFirstName"
> columnIndex="..."/>
> <result
> property="customerDependentVo.depLastName" columnIndex ="..."/>
>
> Brandon Goodin
> Silver Mind Software
> http://www.silvermindsoftware.com
> bgoodin@silvermindsoftware.com
> 615-306-3652
> http://www.linkedin.com/in/bgoodin
>
>
>
> On Fri, Mar 27, 2009 at 11:03 AM, Jasmin Mehta <Ja...@nexweb.org>wrote:
>
>>
>> I can not change the column names of table QOL_DEPENDENT
>>
>> from FIRST_NAME to DEP_FIRST_NAME
>>
>> It has to be the same.
>>
>>
>> From: Brandon Goodin <br...@gmail.com> To:
>> user-java@ibatis.apache.org
>> Date: 03/27/2009 11:59 AM Subject: Re: How to define alias in <resultMap>
>> ------------------------------
>>
>>
>> <typeAlias alias="customerVo"
>> type="org.nexweb.qol.gcc.model.CustomerVO"/>
>>
>> <resultMap id="customerRS" class="customerVo">
>> <result property="custStatus" column="CUST_STATUS"/>
>> <result property="firstName" column="FIRST_NAME"/>
>> <result property="middleName" column="MIDDLE_NAME"/>
>> <result property="lastName" column="LAST_NAME"/>
>> <result property="customerDependentVo.depFirstName"
>> column="DEP_FIRST_NAME"/>
>> <result property="customerDependentVo.depLastName"
>> column="DEP_LAST_NAME"/>
>> </resultMap>
>>
>>
>> <select id="getListOfCustomersBySSNMask" resultMap="customerRS"
>> parameterClass="java.util.Map">
>> SELECT
>> cs.cust_status, cu.first_name, cu.middle_name,
>> cu.last_name,
>> dep.first_name as dep_first_name, dep.last_name as
>> dep_last_name
>> FROM
>> qol_customer cu,
>> qol_dependent dep
>> WHERE
>> AND cu.cust_id = dep.cust_id (+)
>> </select>
>>
>> public class CustomerVO implements Serializable {
>> private Integer custId;
>> private Integer custStatus;
>> private String firstName;
>> private String middleName;
>> private String lastName;
>>
>> private CustomerDependentVO customerDependentVo;
>> ... all the accessor methods
>>
>> }
>>
>> public class CustomerDependentVO implements Serializable
>> {
>> private Integer custId;
>> private String depFirstName;
>> private String depLastName;
>> private String depMiddleName;
>>
>> ... all the accessors
>> }
>>
>>
>> ******************************************************************************
>> This email and any files transmitted with it are intended solely for
>> the use of the individual or agency to whom they are addressed.
>> If you have received this email in error please notify the Navy
>> Exchange Service Command e-mail administrator. This footnote
>> also confirms that this email message has been scanned for the
>> presence of computer viruses.
>>
>> Thank You!
>> *
>> ******************************************************************************
>> *
>>
>
>
Re: How to define alias in
Posted by Brandon Goodin <br...@gmail.com>.
You can specify the columnIndex (yuck).
<result property="customerDependentVo.depFirstName"
columnIndex="..."/>
<result
property="customerDependentVo.depLastName" columnIndex ="..."/>
Brandon Goodin
Silver Mind Software
http://www.silvermindsoftware.com
bgoodin@silvermindsoftware.com
615-306-3652
http://www.linkedin.com/in/bgoodin
On Fri, Mar 27, 2009 at 11:03 AM, Jasmin Mehta <Ja...@nexweb.org>wrote:
>
> I can not change the column names of table QOL_DEPENDENT
>
> from FIRST_NAME to DEP_FIRST_NAME
>
> It has to be the same.
>
>
> From: Brandon Goodin <br...@gmail.com> To:
> user-java@ibatis.apache.org
> Date: 03/27/2009 11:59 AM Subject: Re: How to define alias in <resultMap>
> ------------------------------
>
>
> <typeAlias alias="customerVo"
> type="org.nexweb.qol.gcc.model.CustomerVO"/>
>
> <resultMap id="customerRS" class="customerVo">
> <result property="custStatus" column="CUST_STATUS"/>
> <result property="firstName" column="FIRST_NAME"/>
> <result property="middleName" column="MIDDLE_NAME"/>
> <result property="lastName" column="LAST_NAME"/>
> <result property="customerDependentVo.depFirstName"
> column="DEP_FIRST_NAME"/>
> <result property="customerDependentVo.depLastName"
> column="DEP_LAST_NAME"/>
> </resultMap>
>
>
> <select id="getListOfCustomersBySSNMask" resultMap="customerRS"
> parameterClass="java.util.Map">
> SELECT
> cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
> dep.first_name as dep_first_name, dep.last_name as
> dep_last_name
> FROM
> qol_customer cu,
> qol_dependent dep
> WHERE
> AND cu.cust_id = dep.cust_id (+)
> </select>
>
> public class CustomerVO implements Serializable {
> private Integer custId;
> private Integer custStatus;
> private String firstName;
> private String middleName;
> private String lastName;
>
> private CustomerDependentVO customerDependentVo;
> ... all the accessor methods
>
> }
>
> public class CustomerDependentVO implements Serializable
> {
> private Integer custId;
> private String depFirstName;
> private String depLastName;
> private String depMiddleName;
>
> ... all the accessors
> }
>
>
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!
> *
> ******************************************************************************
> *
>
Re: How to define alias in
Posted by Larry Meadors <la...@gmail.com>.
You just have to change the result map.
Larry
On Fri, Mar 27, 2009 at 10:03 AM, Jasmin Mehta <Ja...@nexweb.org> wrote:
>
> I can not change the column names of table QOL_DEPENDENT
>
> from FIRST_NAME to DEP_FIRST_NAME
>
> It has to be the same.
>
>
> From: Brandon Goodin <br...@gmail.com>
> To:
> user-java@ibatis.apache.org
> Date: 03/27/2009 11:59 AM
> Subject: Re: How to define alias in <resultMap>
> ________________________________
>
> <typeAlias alias="customerVo"
> type="org.nexweb.qol.gcc.model.CustomerVO"/>
>
> <resultMap id="customerRS" class="customerVo">
> <result property="custStatus" column="CUST_STATUS"/>
> <result property="firstName" column="FIRST_NAME"/>
> <result property="middleName" column="MIDDLE_NAME"/>
> <result property="lastName" column="LAST_NAME"/>
> <result property="customerDependentVo.depFirstName"
> column="DEP_FIRST_NAME"/>
> <result property="customerDependentVo.depLastName"
> column="DEP_LAST_NAME"/>
> </resultMap>
>
>
> <select id="getListOfCustomersBySSNMask" resultMap="customerRS"
> parameterClass="java.util.Map">
> SELECT
> cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
> dep.first_name as dep_first_name, dep.last_name as
> dep_last_name
> FROM
> qol_customer cu,
> qol_dependent dep
> WHERE
> AND cu.cust_id = dep.cust_id (+)
> </select>
>
> public class CustomerVO implements Serializable {
> private Integer custId;
> private Integer custStatus;
> private String firstName;
> private String middleName;
> private String lastName;
>
> private CustomerDependentVO customerDependentVo;
> ... all the accessor methods
>
> }
>
> public class CustomerDependentVO implements Serializable
> {
> private Integer custId;
> private String depFirstName;
> private String depLastName;
> private String depMiddleName;
>
> ... all the accessors
> }
>
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!
> ******************************************************************************
Re: How to define alias in
Posted by Jasmin Mehta <Ja...@nexweb.org>.
I can not change the column names of table QOL_DEPENDENT
from FIRST_NAME to DEP_FIRST_NAME
It has to be the same.
From:
Brandon Goodin <br...@gmail.com>
To:
user-java@ibatis.apache.org
Date:
03/27/2009 11:59 AM
Subject:
Re: How to define alias in <resultMap>
<typeAlias alias="customerVo"
type="org.nexweb.qol.gcc.model.CustomerVO"/>
<resultMap id="customerRS" class="customerVo">
<result property="custStatus" column="CUST_STATUS"/>
<result property="firstName" column="FIRST_NAME"/>
<result property="middleName" column="MIDDLE_NAME"/>
<result property="lastName" column="LAST_NAME"/>
<result property="customerDependentVo.depFirstName"
column="DEP_FIRST_NAME"/>
<result property="customerDependentVo.depLastName"
column="DEP_LAST_NAME"/>
</resultMap>
<select id="getListOfCustomersBySSNMask" resultMap="customerRS"
parameterClass="java.util.Map">
SELECT
cs.cust_status, cu.first_name, cu.middle_name,
cu.last_name,
dep.first_name as dep_first_name, dep.last_name as
dep_last_name
FROM
qol_customer cu,
qol_dependent dep
WHERE
AND cu.cust_id = dep.cust_id (+)
</select>
public class CustomerVO implements Serializable {
private Integer custId;
private Integer custStatus;
private String firstName;
private String middleName;
private String lastName;
private CustomerDependentVO customerDependentVo;
... all the accessor methods
}
public class CustomerDependentVO implements Serializable
{
private Integer custId;
private String depFirstName;
private String depLastName;
private String depMiddleName;
... all the accessors
}
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
******************************************************************************
Re: How to define alias in
Posted by Brandon Goodin <br...@gmail.com>.
<typeAlias alias="customerVo"
type="org.nexweb.qol.gcc.model.CustomerVO"/>
<resultMap id="customerRS" class="customerVo">
<result property="custStatus" column="CUST_STATUS"/>
<result property="firstName" column="FIRST_NAME"/>
<result property="middleName" column="MIDDLE_NAME"/>
<result property="lastName" column="LAST_NAME"/>
<result property="customerDependentVo.depFirstName"
column="DEP_FIRST_NAME"/>
<result property="customerDependentVo.depLastName"
column="DEP_LAST_NAME"/>
</resultMap>
<select id="getListOfCustomersBySSNMask" resultMap="customerRS"
parameterClass="java.util.Map">
SELECT
cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
dep.first_name as dep_first_name, dep.last_name as
dep_last_name
FROM
qol_customer cu,
qol_dependent dep
WHERE
AND cu.cust_id = dep.cust_id (+)
</select>
public class CustomerVO implements Serializable {
private Integer custId;
private Integer custStatus;
private String firstName;
private String middleName;
private String lastName;
private CustomerDependentVO customerDependentVo;
... all the accessor methods
}
public class CustomerDependentVO implements Serializable
{
private Integer custId;
private String depFirstName;
private String depLastName;
private String depMiddleName;
... all the accessors
}
AW: How to define alias in
Posted by Benjamin Klatt <be...@bar54.de>.
Hi Jasmin,
you should be able to set different column names in your resultmap like
<resultMap id="customerRS" class="customerVo">
<result property="custStatus" column="CUST_STATUS"/>
<result property="firstName" column="FIRST_NAME"/>
<result property="middleName" column="MIDDLE_NAME"/>
<result property="lastName" column="LAST_NAME"/>
<result property="customerDependentVo.depFirstName"
column="CDV_FIRST_NAME"/>
<result property="customerDependentVo.depLastName" column="
CDV_LAST_NAME"/>
</resultMap>
And then use appropriate aliases in your sql query:
<select id="getListOfCustomersBySSNMask" resultMap="customerRS"
parameterClass="java.util.Map">
SELECT
cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
dep.first_name as cdv_first_name, dep.last_name as
cdv_last_name
FROM
qol_customer cu,
qol_dependent dep
WHERE
AND cu.cust_id = dep.cust_id (+)
</select>
cheers
benjamin
_____
Von: Jasmin Mehta [mailto:Jasmin_Mehta@nexweb.org]
Gesendet: Freitag, 27. März 2009 17:52
An: user-java@ibatis.apache.org
Betreff: How to define alias in <resultMap>
Hi,
With below code how do I get correct value for dependent first name and
dependent last name? Right now as both qol_customer and qol_dependet has
same field name for FIRST_NAME and LAST_NAME, I am getting qol_customer's
FIRST_NAME and LAST_NAME populated in
customerDependentVo.depFirstName
customerDependentVo.depLastName
properties. Is there any way I can define in <resultMap> that such field is
coming from such and such table?
Thanks
Jasmin
<typeAlias alias="customerVo"
type="org.nexweb.qol.gcc.model.CustomerVO"/>
<resultMap id="customerRS" class="customerVo">
<result property="custStatus" column="CUST_STATUS"/>
<result property="firstName" column="FIRST_NAME"/>
<result property="middleName" column="MIDDLE_NAME"/>
<result property="lastName" column="LAST_NAME"/>
<result property="customerDependentVo.depFirstName"
column="FIRST_NAME"/>
<result property="customerDependentVo.depLastName"
column="LAST_NAME"/>
</resultMap>
<select id="getListOfCustomersBySSNMask" resultMap="customerRS"
parameterClass="java.util.Map">
SELECT
cs.cust_status, cu.first_name, cu.middle_name, cu.last_name,
dep.first_name, dep.last_name
FROM
qol_customer cu,
qol_dependent dep
WHERE
AND cu.cust_id = dep.cust_id (+)
</select>
public class CustomerVO implements Serializable {
private Integer custId;
private Integer custStatus;
private String firstName;
private String middleName;
private String lastName;
private CustomerDependentVO customerDependentVo;
... all the accessor methods
}
public class CustomerDependentVO implements Serializable
{
private Integer custId;
private String depFirstName;
private String depLastName;
private String depMiddleName;
... all the accessors
}
****************************************************************************
**
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.
Thank You!
****************************************************************************
**