简体   繁体   中英

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.
After the mapping the arrayList of object B is 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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