Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/DesignDocs/293925/MOXyExtensions/ObjectReferenceMapping

XMLObjectReferenceMapping

Requirements

Provide support for XML object reference mapping configuration via XML metadata file.

The following should be configurable:

Design

Basic XML object reference mapping support

We will extend our current xml-element and xml-attribute support to allow object reference mapping configuration. For example, the following XML metadata snippet would be used to setup an object reference mapping for 'workAddress':

<xml-attribute java-attribute="workAddress" xml-idref="true"/>

Where the following exists in Address:

<xml-attribute java-attribute="id" xml-id="true" required="true" />

If workAddress was to be mapped to an attribute named work-address-id, then the following would be used:

<xml-attribute java-attribute="workAddress" xml-path="@work-address-id" xml-idref="true"/>

Where the following exists in Address:

<xml-attribute java-attribute="id" xml-id="true" required="true" />

Example:

The following example will demonstrate how to configure XML object reference mappings via XML metadata by using xml-element and xml-attribute.

org.example.Root.java

package org.example;
 
public class Root {
    public List<Employee> employees;
    public List<Address> addresses;
}

org.example.Employee.java

package org.example;
 
public class Employee {
    public Address workAddress;
}

org.example.Address.java

package org.example;
 
public class Address {
    public String id;
}

Deployment XML

 

XML Instance Document

<?xml version="1.0" encoding="UTF-8"?>
<document-root>
    <employees>
        <employee>
            <contact-info>
                <work-address work-address-id="101" />
            </contact-info>
        </employee>
    </employees>
    <addresses>
        <address aid="100" />
        <address aid="101" />
        <address aid="102" />
    </addresses>
</document-root>

org/example/eclipselink-oxm.xml

This XML file demonstrates configuring XML object reference mappings on the "org.example.Employee" class.

<?xml version="1.0" encoding="US-ASCII"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
    <java-types>
        <java-type name="org.example.Root">
            <xml-root-element name="document-root" />
            <java-attributes>
                <xml-element java-attribute="employees" xml-path="employees/employee" />
                <xml-element java-attribute="addresses" xml-path="addresses/address" />
            </java-attributes>
        </java-type>
        <java-type name="org.example.Employee">
            <java-attributes>
                <xml-attribute java-attribute="workAddress" xml-path="contact-info/work-address/@work-address-id" xml-idref="true"/>
            </java-attributes>
        </java-type>
        <java-type name="org.example.Address">
            <java-attributes>
                <xml-attribute java-attribute="id" xml-path="@aid" xml-id="true" required="true" />
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>

Open Issues

This section lists the open issues that are still pending that must be decided prior to fully implementing this project's requirements.

Issue# Owner Description/Notes

Decisions

This section lists decisions made. These are intended to document the resolution of open issues or constraints added to the project that are important.

Issue# Description/Notes Decision

Back to the top