Spring MVC: How to allow null values in top-level field in Dozer through API?

377 views Asked by At

I am using Dozer to map between entities and DTO's and I want to allow an null value of Date type in top-level field of my DTO.

Exclusion of field works fine, but this is not satisfactory solution because then it is always mapped to null:

mapping(InspectionInterval.class, InspectionIntervalDTO.class)
    .exclude("lastPerformedOn");

I would like to do something like:

mapping(InspectionInterval.class, InspectionIntervalDTO.class)
    .fields("lastPerformedOn", "lastPerformedOn", FieldsMappingOptions.allowNull());

In the documentation, there is just example how to do it using XML configuration, but I am not able to figure out how to do it using API: http://dozer.sourceforge.net/documentation/advancedConfiguration.html

Any help is much appreciated!

Thanks, Richard

1

There are 1 answers

0
trebi On BEST ANSWER

Solved by switching to XML configuration.