ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jasmin Mehta <Jasmin_Me...@nexweb.org>
Subject How to define alias in <resultMap>
Date Fri, 27 Mar 2009 15:51:58 GMT
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!            
******************************************************************************


Mime
View raw message