How can I map one object to another (existing) excluding null fields?
For example:
class A {
String a1;
String a2;
}
class B {
String a1;
String a2;
}
In A object I have non null field a1, on B object I have non null field a2. Is there any way to map object A to object B exclude field a2? Without custom converter and without excluding this field in mapping.xml?
You should use map-null
attribute on <mapping>
element in your dozer-configuration-mapping.xml
file:
<mapping map-null="false">
<class-a>your.package.A</class-a>
<class-b>your.package.B</class-b>
</mapping>