Overriding metadata through XML.1.4. Association level metadata

Overriding metadata through XML.1.4. Association level metadata

You can define XML overriding for associations. All association level metadata behave in entity/attributes, mapped-superclass/attributes or embeddable/attributes.

    <attributes>
        <one-to-many name="players" fetch="EAGER">
            <map-key name="name"/>
            <join-column name="driver"/>
            <join-column name="number"/>
        </one-to-many>
        <many-to-many name="roads" target-entity="Administration">
            <order-by>maxSpeed</order-by>
            <join-table name="bus_road">
                <join-column name="driver"/>
                <join-column name="number"/>
                <inverse-join-column name="road_id"/>
                <unique-constraint>
                    <column-name>driver</column-name>
                    <column-name>number</column-name>
                </unique-constraint>
            </join-table>
        </many-to-many>
        <many-to-many name="allTimeDrivers" mapped-by="drivenBuses">
    </attributes>

You can override an association through one-to-many, one-to-one, many-to-one, and many-to-many. Each of these elements can have subelements accordingly: join-table (which can have join-columns and inverse-join-columns), join-columns, map-key, and order-by. mapped-by and target-entity can be defined as attributes when it makes sense. Once again the structure is reflects the annotations structure. You can find all semantic informations in the chapter describing annotations.