问题
How do you map a single field into a Set
in Dozer?
I have a class like:
class FooDTO {
private IdDto bar;
private IdDto baz;
}
class FooDomainObject {
private List<Id> ids;
}
I'd like to map bar
and baz
into the ids
list, but I can't get it to do this.
回答1:
I found this on the Dozer support list:
http://sourceforge.net/projects/dozer/forums/forum/452530/topic/1557144
Basically, you use this syntax:
<field>
<a>bar</a>
<b>ids[0]</b>
<b-hint>org.foo.Id</b-hint>
</field>
<field>
<a>baz</a>
<b>ids[1]</b>
<b-hint>org.foo.Id</b-hint>
</field>
回答2:
Is there a way to do sth. like this :
<mapping>
<class-a>SourceObject</class-a>
<class-b>blaObject</class-b>
<field>
<a>sourceObjectSubObject[standardID].fielda</a>
<b>blaDestField</b>
</field>
</mapping>
Where the standardID
is a field in the sourceObject
,
and the sourceObjectSubObject
is a List<sourceObjectSubObject>
.
来源:https://stackoverflow.com/questions/4801593/dozer-map-single-field-to-set