1

Is there a way to exclude multiple fields in Dozer, when source and target classes are the same?

I am using it like this:

<mapping map-null="false" wildcard="true">
    <class-a>com.abc</class-a>
    <class-b>com.abc</class-b>
    <field-exclude>
        <a>field1</a> 
        <b>field1</b> 
    </field-exclude>
    <field-exclude>
        <a>field2</a> 
        <b>field2</b> 
    </field-exclude> ....                                                   
</mapping>

It seems so funny to write same name when it's known that it'll always be same for all... Is there any alternative?

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Prateek Singh
  • 1,106
  • 10
  • 18

2 Answers2

3

I found this post in Google, but I configure Dozer via annotations so the existing answer didn't help me.

In order to exclude a field from mapping via annotations use @Mapping("this") on the field.

Source: Dozer, how to ignore a field with annotation

Community
  • 1
  • 1
naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
2
wildcard="false"

will do the trick. http://dozer.sourceforge.net/documentation/exclude.html