When mapping object A to B, the expected behaviour (and the whole raison d'être of Dozer) is that after the mapping, object B will be an image of object A.
However, if mapping to an initialized instance of B, collection fields will not be "mapped" but instead all elements from the A side will be added to the B side, which will result in duplicates with default settings..
To achieve proper mirroring, I need to specify relationship-type=non-cumulative (to not add elements already present on the B side) AND remove-orphans=true (to remove elements on the B side that are not present on the A side). This is rather complicated and counterintuitive. I believe the default for the relationship-type and remove-orphans should be respectively non-cumulative and true, OR there should be an simple option to specify that we want mirroring of the collection (not some kind of merging).
Alternately, I can also reset the collection on the B side before invoking Dozer, which is probably more efficient than applying the described settings.
For better understanding, here's my use case: I want to update a hibernate entity from a DTO sent by the client. If the entity doesn't yet exist in the DB, I map to a newly created instance, no problem. But if the entity already exists, I load it and map the DTO to it. And if I don't take precautions, I get duplicates in my entity's collections because all elements from the DTO side are added to the entity side. I would expect the default to be just a simple mirroring of collections, just as with basic types, whether the target instance is initialized or not.
I totally agree with you - we spent several hours debugging dozer to find out that adding already existing elements and not-removing no longer existing elements is as-designed and not a dozer bug. I strongly suggest to change that default behavior.