简体   繁体   中英

Orika does not set value on destination when null

I am facing a problem with Orika when trying to set null on the destination.

Right now my implementation works pretty well when the source has a value and the destination is null. It also works both source and destination have a value. The problem is when the value that i read from the source is null while on the destination is not.

I found that on version 1.4.0 the functions ClassMapBuilder.mapNulls(true|false) or ClassMapBuilder.mapNullsInReverse(true|false) can be used to solve this problem.

Unfortunately the above code does not seem to solve my problem, thus the destination field remains always unchanged although it should be set to null (according to the source).

Here are the different implementations that i tried.

 MapperFactory myfact = new DefaultMapperFactory.Builder().build();
 ClassMapBuilder<E, D> mapBuilder = factory.classMap(dest, source).mapNulls(true);


 MapperFactory myfact = new DefaultMapperFactory.Builder().mapNulls(true).build();
 ClassMapBuilder<E, D> mapBuilder = factory.classMap(dest, source);

Any suggestions?

This was finally a problem in the Orika software. The bug was fixed in release 1.4.2

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