I am looking at bean mappings to clean up hibernate entities. The goals are:
- Only keep initialized Entities and Collections
- Drop not initialized entities, replace them by null
- Drop not initialized Collections and replace them with there empty versions
- Get rid of hibernate specific types like PersistentBag, and others
- Get rid of initialized JavaAssist proxies
- The possibility to make required configuration within code, no external configuration for the mappings
With the CustomFieldMapper it is possible to achieve my goals. Before Dozer maps a field it calls my CustomFieldMapper. Inspecting the parameters I can decide if I want to map the field or opt out and let Dozer do its thing. When you decide to map the field, it is your responsibility to ensure the deep mapping.
ModelMapper I could not find a way to hock into each and every mapping. To me it seems that I have to write an explicit type mapping for each class I want to check.
[list of bean mappers] (http://www.halyph.com/2013/10/java-object-to-object-mapper.html) [stackoverflow list of bean mappers] (http://stackoverflow.com/questions/1432764/any-tool-for-java-object-to-object-mapping)