简体   繁体   English

推土机映射对象中包含的ArrayList

[英]Dozer mapping ArrayList contained in object

I have an object A that contain an arrayList and I want to map it to an object B with the same structure of A. 我有一个包含arrayList的对象A,我想将其映射到具有A相同结构的对象B。
After the mapping the arrayList of object B is null. 映射之后,对象B的arrayList为null。 I tried this mapping. 我尝试了这种映射。

<mapping type="bi-directional">
    <class-a>it.firstpackage.A</class-a>
    <class-b>it.secondpackage.B</class-b>
    <field copy-by-reference="true">
        <a>collection</a>
        <b>collection</b>
        <a-hint>it.firstpackage.ListA</a-hint>
        <b-hint>it.secondpackage.ListB</b-hint>
    </field>
</mapping>

Can you tell me where I am wrong? 你能告诉我我哪里错了吗?
Thanks in advance and sorry for my english 预先感谢,对不起我的英语

You are trying to map collection by reference what tells dozer not to map subelements but copy the value as it is. 您正在尝试通过引用来映射集合,这会告诉推土机不要映射子元素,而是照原样复制值。 But this way it cannot copy the property since they are of different types. 但是,由于属性类型不同,因此无法复制属性。 Try removing copy-by-reference and add mapping between lista and listb if needed. 尝试删除按引用复制,并在需要时在lista和listb之间添加映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM