Dozer: map single field to Set

允我心安 提交于 2019-12-13 02:17:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!