Any way to set remove-orphans="true" as a top level configuration option

78 views
Skip to first unread message

Ryan Jones

unread,
Nov 27, 2017, 4:36:33 AM11/27/17
to Dozer Mapper
I've got a use case where I'd like to set remove-orphans="true" for all collections.

Whilst I can set up my XML mappings config file to specify all of these, if new collections are added to the object class, the developer will need to remember to update the XML dozer configuration to include the remove-orphans="true" - which inevitably someone will forget to at some point down the line.

Thanks,
Ryan

Ryan Jones

unread,
Nov 27, 2017, 5:22:19 AM11/27/17
to Dozer Mapper
To explain further, what I believe i'd currently have to do within my XML configiration is:

<mapping>
       
<class-a>classA</class-a>
       
<class-b>classA</class-b>  
       
<field remove-orphans="true">
           
<a>collectionAField</a>
           
<b>collectionAField</b>
       
</field>
       
<field remove-orphans="true">
           
<a>collectionBField</a>
           
<b>collectionBField</b>
       
</field>
</mapping>


To define the field mapping and remove-orphans for all collections of ClassA (and all it's sub classes) is tedious. It's also open to failure if new collections are added and the config here not updated.

Ideally, there would be a global configuration option for remove-orphans, where any collection will use the value of the global configuration, unless it's been overridden.

Something like the following would be easier, but it would still require me to update the mappings XML config whenever new subclasses of classA are added.

<mapping remove-orphans="true">
       
<class-a>classA</class-a>
       
<class-b>classA</class-b>
</mapping>

For all collections within ClassA when mapping to the same object, remove-orphans="true" will be used.

Thanks,
Ryan

Gareth Healy

unread,
Feb 24, 2018, 9:03:19 AM2/24/18
to Dozer Mapper
remove-orphans is only on a field. If you wanted it on global configuration, a PR would need to be raised.


On Monday, 27 November 2017 09:36:33 UTC, Ryan Jones wrote:
Reply all
Reply to author
Forward
0 new messages