I'd like to map a composition without using the deep mapping property of Dozer.
Another important element is that the composed class and the main class map to the same class
I've searched on SO, the Dozer documentation (which is good by the way), but I still, haven't found what I'm looking for
Example : A and B -> C
Class A {
B b
a1
}
Class B {
b1
b2
}
Class C {
ca1
cb1
cb2
}
I don't want to map like :
<mapping>
<class-a>A</class-a>
<class-b>C</class-b>
<field>
<a>b.b1</a>
<b>cb1</b>
</field>
etc.
</mapping>
I'd like to use something like :
<mapping>
<class-a>B</class-a>
<class-b>C</class-b>
<field>
<a>b1</a>
<b>cb1</b>
</field>
etc.
</mapping>
<mapping>
<class-a>A</class-a>
<class-b>C</class-b>
<field>
<a>a1</a>
<b>ca1</b>
</field>
</mapping>
My class B is used with composition in others classes.
I'd like to respect DRY (Don't Repeat Yourself).
There is no solution, except using deep mapping and repeating it, unfortunately.
The problem would be for Dozer to map C -> A and B. It's not easily possible.
One solution would be to able this type of auto-mapping in the case of "one-way" mapping.
Complex problem, similar to this Dozer FAQ