I have two data set let's consider Data A and Data B generated from JAXb converter. check the below code snippet,
// Data A
public class CompanyA {
private List<EmployeeA> empList;
}
public class EmployeeA{
private List<AddressA> addList;
}
public class AddressA{
private String city;
}
// Data B
public class CompanyB {
private List<EmployeeB> empList;
}
public class EmployeeB{
private List<AddressB> addList;
}
public class AddressB{
private String city;
}
These are generated JaxB Objects with getter [for all] /setter [for non collection fields] (not mentioned in above code). When I tried mapping with Dozer API only the parent object is mapped but will getting null pointer exception while mapping collection.
Tried below mapping approach to resolve the mapping issue,
mapping(CompanyA.class, CompanyB.class)
.fields(field("empList").accessible(true), field("empList").accessible(true));
But the flaw in the above approach is that if object contains nested list objects than I have to mention for all the objects with accessible(true)
Any other approach that I can try to map all the collection objects, without mentioning all the mapping scenario in mapping configuration.
Added below arguments in project pom.xml to generate setters of all object (including collections).
<configuration>
<arguments>
<argument>-XtoString</argument>
<argument>-Xsetters</argument>
<argument>-Xsetters-mode=direct</argument>
</arguments>
....
</configuration>
This will forcefully generate setters for all the object from JaxB.