ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simpson, Michael" <MSimp...@ATPCO.NET>
Subject How do I resultmap a composite member variable?
Date Thu, 22 Dec 2005 21:31:48 GMT
Assume I have something like the following:
public class Name {
    String firstName;
    String lastName;
    // getter & setter for both
public class Person {
    String ssn;
    Name name;
    // getter & setter for both
And assume I have a table PERSON with columns SSN, FNAME, LNAME
I want to map creating Person objects but I get hung up with the "name" member object that
is composed of two of the columns in the table. I'm writing something like this but it does
not work:
    <resultMap id="namemap" class="Name">
        <result property="firstName" column="FNAME"/>
        <result property="firstName" column="LNAME">
    <resultMap id="personmap" class="Person">
        <result property="SSN" column="ssn"/>
        <result property="name" column="{FNAME, LNAME}" resultMap="namemap"/>
The last line is where I am stuck. I don't want to reference a statement since I already have
the field I want. How do I get the two columns to be composed into the "name" property?

View raw message