Skip Headers

# Mapping a List of Unions

Previous

Next

Use an `EISCompositeDirectCollectionMapping` (with XML records) or an `XMLCompositeDirectCollectionMapping` to map a Java attribute to an `xsd:list` that contains `xsd:union` types, such as:

    <xsd:element name="listOfUnions" type="listOfUnions"/>
        <xsd:simpleType name="listOfUnions">
            <xsd:list>
                <xsd:simpleType>
                    <xsd:union memberTypes="xsd:date xsd:integer"/>
                </xsd:simpleType>
            </xsd:list>
        </xsd:simpleType>

When TopLink marshalls (writes) an object to XML, it does not rely on a single `xsd:list` `itemType`. Instead, for each item in the list, TopLink tries each `memberType` until the first successful conversion.

For more information, see "Mapping to a List of Unions With an XML Composite Direct Collection Mapping". The same applies to an `EISCompositeDirectCollectionMapping` with XML records (see "EIS Composite Direct Collection Mapping").