简体   繁体   中英

Mapping with DOZER without method set

I am trying to convert two classes that have an attribute of type java.util.List, but one of the classes does not have a method "set*" only the method "get*" like this:

<mapping>
        <class-a>com.mycompany.bean.SocioPj</class-a>
        <class-b>com.mycompany.jaxb.SocioPjXml</class-b>
        <field>
            <a set-method="getListaSocios().add">listaSocios</a>
            <b>listaSocios</b>
            <a-hint>com.mycompany.bean.SocioPf,com.mycompany.bean.SocioPj</a-hint>
            <b-hint>com.mycompany.jaxb.SocioPfXml,com.mycompany.jaxb.SocioPjXml</b-hint>
        </field>
    </mapping>

The example above the class: SocioPj doesn´t have a method setListSocios() when I tried to convert I catch this error:

[Time:2015-03-24 11:29:08,055][Level:ERROR][Thread:http-bio-8080-exec-10][OnboardingCCMFulfillmentImpl] org.dozer.MappingException: java.lang.ClassNotFoundException: /add

Has anyone faced this problem?

You can tell Dozer to directly access the field without calling the getter/setter (Even if the field is private ):

<field>
    <a is-accessible="true">listaSocios</a>
    <b>listaSocios</b>
</field>

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