atos1990 / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

Add capability to ignore mapping of null values (instead of setting results NULL) #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
this should be somehow configurable, such as the various other configuration 
options available on the DefaultMapperFactory

Original issue reported on code.google.com by matt.deb...@gmail.com on 19 Oct 2012 at 3:01

GoogleCodeExporter commented 9 years ago
Hi Matt,
Is there any progress on this issue? I was wondering if there is any other null 
values can be ignored in current version.

Thanks.
Marcos

Original comment by marcosla...@gmail.com on 30 Oct 2012 at 6:28

GoogleCodeExporter commented 9 years ago
There's a little progress on this in the current master;
just set .mapNulls(false or true) on DefaultMapperFactory.Builder to configure.

If you get a chance to try out, I'd like to know how this works for you.

Original comment by matt.deb...@gmail.com on 31 Oct 2012 at 3:32

GoogleCodeExporter commented 9 years ago
There's been an update applied to this fix:
now, you can use ClassMapBuilder.mapNulls(true|false) or 
ClassMapBuilder.mapNullsInReverse(true|false) to set defaults on a given 
ClassMapBuilder.

You can also use FieldMapBuilder.mapNulls(true|false) or 
FieldMapBuilder.mapNullsInReverse(true|false) to configure the behavior at an 
individual field mapping level.

If neither has been specified on a given field or classMap, then the default 
global setting will be applied (which can be specified on the 
DefaultMapperFactory.Builder).

Original comment by matt.deb...@gmail.com on 24 Nov 2012 at 6:41

GoogleCodeExporter commented 9 years ago
Implemented in 1.4.0 release

Original comment by matt.deb...@gmail.com on 19 Dec 2012 at 2:09

GoogleCodeExporter commented 9 years ago
I might be doing something wrong or there is still some problem in the mapNulls 
implementation. 

When adding a new value on the source the destination value is updated 
successfully. When the source is null and destination has a value, there is no 
change in the destination at all.

ClassMapBuilder<E, D> mapBuilder = factory.classMap(myEntity, 
myDto).mapNulls(true);

The above does not seem to do the trick. Any suggestions ? 

Original comment by BinaryX...@gmail.com on 22 Mar 2013 at 10:41