Squeez
Squeez

Reputation: 959

Dozer map to existing object non null fields

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?

Upvotes: 1

Views: 2174

Answers (1)

Rozart
Rozart

Reputation: 1788

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>   

Upvotes: 2

Related Questions