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>
<result property="firstName" column="FNAME"/>
<result property="firstName" column="LNAME">
</resultMap>
<resultMap id="personmap"
class="Person">
<result property="SSN" column="ssn"/>
<result property="name" column="{FNAME, LNAME}" resultMap="namemap"/>
<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?
Thanks.
