First of all, by default dozer mappings are bi-directional. So,
mapping from class-a
to class-b
and vice-versa is permitted.
As you have done your mapping as follows:
<field>
<a>strategy.name</a>
<b>strategy.name</b>
</field>
If the source object is having a Strategy
object which is not null and have all the relevant field's value. Then dozer will create a new Strategy
object for destination as well and will only populate the name
field of newly created Strategy
object.
Further, dozer also works on retrospection so suppose the name and type of all fields of Strategy
object in source and destination is same. Dozer will map or copy all the fields automatically. So you don't have to map each field individually. you just have to write as below.
<field>
<a>strategy</a>
<b>strategy</b>
</field>
But if your field names or type is not same, you need to define mapping for each field as you did for id
field for Rule
class and ruleId
field for RuleActivity
class.
<field>
<a>id</a>
<b>ruleId</b>
</field>
Hope this clarifies your doubts.