orika-mapper / orika

Simpler, better and faster Java bean mapping framework
http://orika-mapper.github.io/orika-docs/
Apache License 2.0
1.29k stars 269 forks source link

Excluding field seems not to work when using byDefault #348

Closed ghilainm closed 4 years ago

ghilainm commented 4 years ago

Hi guys, I try to exclude a field when mapping from one entity to another. I am using Orika 1.5.4.

I have tried the two following patterns:

        factory.classMap(Entity.class, Entity.class)
                .byDefault()
                .exclude("property")
                .register();
        factory.classMap(Entity.class, Entity.class)
                .exclude("property")
                .byDefault()
                .register();

The getProperty() method is still invoked by Orika despite I expect it to be excluded from the mapping.

The exclude is visible in the DEBUG logs

09:52:05.157 [Test worker] DEBUG ma.glasnost.orika.metadata.ClassMapBuilder - ClassMap created:
    ClassMapBuilder.map(Entity, Entity)
     .field( property(List<OtherEntity>), property(List<OtherEntity>) )
     .exclude('property')

Any idea?

ghilainm commented 4 years ago

Sorry guys false positive, it was another field mapping which triggered the invocation.