I’m using Dozer to convert my objects. But I’ve a problem to map a simple List…
I retrieve a ResultSet from Hibernate as an Object List and I want to map it to my complex type object.
So, my source is like :
List < Object > list = new ArrayList< Object > ();
list.add("Name");
list.add("Address");
And my Value Object is :
public class MyClass
{
public String name;
public String address;
}
I just want to map list[0] ==> MyClass.name and list[1] ==> MyClass.address properties but I don’t find how…
Thanks for your help !
For some reason Dozer does Not support this (the ideal situation):
It would only map to
namethe whole string representation of theList, so yournameproperty would end up with the value [Name, Address].Your best option would be to put your
Listin a holder class and map it like this:MyHolderclass just contains yourListinstance in theholdedfield and provide access to it with a getter method.In the field mappings
is-accessible="true"is required becauseMyClassproperties arepublicand have no accessors. I recommend you to make those propertiesprivateand create accessor methods.