Menu

#382 remove-orphans and non-cumulative with String List

Dozer v5.3.2
open
nobody
5
2012-08-04
2012-08-04
No

When using remove-orphans and non-cumulative with a String List the reuslt is incorrect. When passing in "a" and the destination has "a","b" the mapped result is empty.

The bug is results from method addOrUpdateToList in class org.dozer.MappingProcessor

On line 771 the case is handled:

if (RelationshipType.NON_CUMULATIVE.equals(fieldMap.getRelationshipType())
&& result.contains(destValue)) {
int index = result.indexOf(destValue);
// perform an update if complex type - can't map strings
Object obj = result.get(index);
// make sure it is not a String
if (obj != null && !obj.getClass().isAssignableFrom(String.class)) {
map(null, srcValue, obj, false, null);
mappedElements.add(obj);
}

So if it is a String this is not added to the mappedElements. Later in line 799 in method removeOrphans the mappedElements Collection is checked, nothing is foudn so all are removed.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB