Always show null object to null
1 answer
This is one common exception, which says that you should not pass a null object as a top-level bean to the mapper.map (src, dest) method. Thus, it is necessary to check the security before calling Dozer.
if (src == null) return null;
return dozer.map(src, dest);
Also, the "map-null" policy is enabled by default, but it only applies to the elements inside the bean that you want to display (not at the top level). Therefore Dozer will render correctly 'user.id'
if it is null. In the next version, it will be possible to apply "map-null" globally without specifying each class. However, it can help to disable the display of zeros as it is enabled by default.
+5
source to share