I have two sets of mappings, one context based and another plain one as shown below.
Set 1:
<mapping map-id="nonidParent">
<class-a>${Parent}</class-a>
<class-b>${ParentBean}</class-b>
<field-exclude>
<a>id</a>
<b>id</b>
</field-exclude>
<field map-id="nonidChild" relationship-type="non-cumulative" remove-orphans="true" >
<a>children</a>
<b>children</b>
<a-hint>${Child}</a-hint>
<b-hint>${ChildBean}</b-hint>
</field>
</mapping>
<mapping map-id="nonidChild">
<class-a>${Child}</class-a>
<class-b>${ChildBean}</class-b>
<field-exclude>
<a>id</a>
<b>id</b>
</field-exclude>
<field>
<a>childType</a>
<b>type</b>
</field>
<field map-id="nonidParent">
<a>parent</a>
<b>parent</b>
<a-hint>${Parent}</a-hint>
<b-hint>${ParentBean}</b-hint>
</field>
</mapping>
Set 2:
<mapping>
<class-a>${Parent}</class-a>
<class-b>${ParentBean}</class-b>
<field relationship-type="non-cumulative" remove-orphans="true" >
<a>children</a>
<b>children</b>
<a-hint>${Child}</a-hint>
<b-hint>${ChildBean}</b-hint>
</field>
</mapping>
<mapping>
<class-a>${Child}</class-a>
<class-b>${ChildBean}</class-b>
<field>
<a>childType</a>
<b>type</b>
</field>
<field>
<a>parent</a>
<b>parent</b>
<a-hint>${Parent}</a-hint>
<b-hint>${ParentBean}</b-hint>
</field>
</mapping>
I have been able to use the above sets in the same project and have noticed the field "id" correctly getting excluded and not based upon the use of the context map-id "nonidParent" and "nonidChild".
However, I am successful at using the above sets only in the method:
destination d = this.mapper.map(source, destination.class, "nonidParent").
But the the object to object map method is not copying the nested objects as expected.
this.mapper.map(source, destination, "nonidParent")
The method above successfully excludes copying the id field for the parent but does not exclude the id field (as specified in the nonidChild) for the child objects. Am I missing something in my config files?
I am using the latest 5.3.2 version of Dozer.