Paul Newport wrote:
I have the following setup:
A class called Address that contains a String (post code) and a List (of address lines).
On the database this is stored as a CHAR for the post code, and 5 separate address CHAR line fields (i.e addressLine1, addressLine2 etc).
The database design is nothing to do with me and unfortunately I am stuck with it.
Is there an easy way of mapping element 0 of the list to addressLine1, element 1 to addressLine2 etc.
Basically I am stuck with the database and the object model, so my only option is to do something clever in the mapping file.
Thanks.
Why don't you inroduce five getters/setters in your object?
public String getAddressLine1()
{
return mylist.get(0);
}
public void setAddressLine1(String addressLine1)
{
return mylist.set(0, addressLine1);
}