简体   繁体   中英

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?

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>   

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM