I tied to map a list with a hierarchy and I find 2 problems.
<mapping>
<class-a>CLASSA</class-a>
<class-b>CLASSB</class-b>
<field relationship-type="non-cumulative">
<a>listA</a>
<b set-method= "addInListB" type="iterate">listB </b>
<a-hint> classX, classY, classZ </a-hind>
<b-hint> classS, classT, classU </b-hint>
</field>
</mapping>
First problem was that if I tried to add more than 1 hint, dozer threw a NullPointerException because fieldMapping.getDestHintContainer().getHint() returns null in case of more hints than 1. Instead of this I introduced in mapFromIterateMethodFieldMap method: fieldMapping.getDestHintType(value.getClass())
The second problem when I tried to map a hierarchy with a base object, dozer tried to map everything to the base object even in the xml there was the list of hints of destination.
The problem was in mapCollection method because in case of a generic type dozer update the DestHintContainer even it is set with the custom mapping xml.
Before update this hint list, I tested it if it is needed or not.
if (fieldMap.getDestHintContainer() == null) {
fieldMap.setDestHintContainer(destHintContainer);
}
hint problem in case of list with a hierarchy
Same "bug" and solution found:
line 588 in MappingProcessor (@958), change from
value = map(value, fieldMapping.getDestHintContainer().getHint());
to
value = map(value, fieldMapping.getDestHintType(value.getClass()));
Would be nice to have this in trunk.
Thanks in advance.
View and moderate all "patches Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Patches"
Same "bug". I'm using version 5.2.2
Don't you need a remove-method param?
Actually there are several other calls to getDestHintContainer().getHint(). All should be eliminated.
Check this bug report:
http://sourceforge.net/tracker/?func=detail&aid=3008059&group_id=133517&atid=727368
It is about the same problem, I have created a unit test for this, but there is no answer to it yet. It might be that the problem is more complex than we think.