Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAXB does not create set methods for List [duplicate]

I have this three types in a XSD:

<xs:element name="Account" type="Account"/>
<xs:element name="Operation" type="Operation"/>
<xs:element name="Transaction" type="Transaction"/>

<xs:complexType name="Operation">
        <xs:sequence>
            <xs:element name="id" type="xs:long"/>
            <xs:element name="type" type="EnumOperationType"/>
            <xs:element name="balance" type="xs:double"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Transaction">
        <xs:sequence>
            <xs:element name="id" type="xs:long"/>
            <xs:element name="type" type="EnumOperationType"/>
            <xs:element name="amount" type="xs:double"/>
            <xs:element name="isCredit" type="xs:boolean"/>
            <xs:element name="isDebit" type="xs:boolean"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Account">
        <xs:sequence>
            <xs:element name="agencyNumber" type="xs:long"/>
            <xs:element name="accountNumber" type="xs:long"/>
            <xs:element name="owner" type="client:Client"/>
            <xs:element name="balance" type="xs:double"/>
            <xs:element maxOccurs="unbounded" ref="Operation"/>
            <xs:element maxOccurs="unbounded" ref="Transaction"/>
        </xs:sequence>
    </xs:complexType>

When I generate the respectively java objects for them using JABX, I only get set() methods for the first four fields: agecy, account, owner and balance.

How to set the lists in a complex object? Do I have to use the ObjectFactory in any way?

Best, Pedro.

like image 643
Pedro Dusso Avatar asked Oct 20 '25 04:10

Pedro Dusso


1 Answers

You can do add on addAll on what is returned from the get method to set the content on the List property.

like image 59
bdoughan Avatar answered Oct 22 '25 19:10

bdoughan