According to this example you can do Deep Mapping with Dozer :
http://dozer.sourceforge.net/documentation/deepmapping.html
<mapping> <class-a>com.github.dozermapper.core.vo.deep.SrcDeepObj</class-a> <class-b>com.github.dozermapper.core.vo.deep.DestDeepObj</class-b> <field> <a>srcNestedObj.src1</a> <b>dest1</b> </field> <field> <a>srcNestedObj.src2</a> <b>dest2</b> </field> <field> <a>srcNestedObj.srcNestedObj2.src5</a> <b>dest5</b> </field> </mapping>
Similarly I want to exclude few nested objects and fields, and so I tried same way :
<mapping map-id="case1" map-null="false"> <class-a>com.server.dal.entities.ClassA</class-a> <class-b>com.server.dal.dto.ClassB</class-b> <field-exclude> <a>childObj1.childObj2</a> <b>childObj1.childObj2</b> </field-exclude> <field-exclude> <a>childObj1.childObj3.testMap</a> <b>childObj1.childObj3.testMap</b> </field-exclude> </mapping>
But this is not working as expected. Is there any other way how to exclude nested Object's fields?
You can exclude nested objects as follows :
<mapping map-id="caseClassA" map-null="false"> <class-a>com.server.dal.entities.ClassA</class-a> <class-b>com.server.dal.dto.ClassB</class-b> <field map-id="excludeSubItem1"> <a>childObj1</a> <b>childObj1</b> </field> </mapping>
<mapping map-id="excludeSubitem1" map-null="false"> <class-a>com.server.dal.entities.ClassChild1</class-a> <class-b>com.server.dal.dto.ClassChild1</class-b> <field-exclude> <a>childObj2</a> <b>childObj2</b> </field-exclude> <field map-id="excludeSubItem2"> <a>childObj3</a> <b>childObj3</b> </field> </mapping>
<mapping map-id="excludeSubitem2" map-null="false"> <class-a>com.server.dal.entities.ClassChild3</class-a> <class-b>com.server.dal.dto.ClassChild3</class-b> <field-exclude> <a>testMap</a> <b>testMap</b> </field-exclude> </mapping>