Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/DesignDocs/293925/MOXyExtensions/XmlCollectionReferenceMapping"
(→Basic XML collection reference mapping support) |
|||
(One intermediate revision by the same user not shown) | |||
Line 50: | Line 50: | ||
public class Employee { | public class Employee { | ||
public List<Address> workAddresses; | public List<Address> workAddresses; | ||
+ | |||
+ | public List<Address> getWorkAddresses() { | ||
+ | return workAddresses; | ||
+ | } | ||
+ | |||
+ | public void setWorkAddresses(List<Address> workAddresses) { | ||
+ | this.workAddresses = workAddresses; | ||
+ | } | ||
+ | |||
} | } | ||
</source> | </source> | ||
Line 99: | Line 108: | ||
<java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Employee"> | <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Employee"> | ||
<java-attributes> | <java-attributes> | ||
− | <xml-element java-attribute="workAddresses" xml-path="contact-info/work-address-id/text()" xml-idref="true" /> | + | <xml-element java-attribute="workAddresses" xml-path="contact-info/work-address-id/text()" xml-idref="true"> |
+ | <xml-access-methods get-method="getWorkAddresses" set-method="setWorkAddresses" /> | ||
+ | </xml-element> | ||
</java-attributes> | </java-attributes> | ||
</java-type> | </java-type> |
Revision as of 11:01, 8 April 2010
XMLCollectionReferenceMapping
Requirements
Provide support for XML collection reference mapping configuration via XML metadata file.
The following should be configurable:
Design
Basic XML collection reference mapping support
We will extend our current xml-element
and xml-attribute
support to allow collection reference mapping configuration. For example, the following XML metadata snippet would be used to setup a collection reference mapping for 'workAddresses':
<xml-element java-attribute="workAddresses" xml-idref="true" />
Where the following exists in Address:
<xml-attribute java-attribute="id" xml-id="true" required="true" />
If workAddresses
was to be mapped to an element named work-address-id
, then the following would be used:
<xml-element java-attribute="workAddresses" xml-path="work-address-id/text()" 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 collection 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 List<Address> workAddresses; public List<Address> getWorkAddresses() { return workAddresses; } public void setWorkAddresses(List<Address> workAddresses) { this.workAddresses = workAddresses; } }
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> <employee> <contact-info> <work-address-id>100</work-address-id> <work-address-id>101</work-address-id> </contact-info> </employee> <addresses> <address aid="100" /> <address aid="101" /> <address aid="102" /> </addresses> </document-root>
org/example/eclipselink-oxm.xml
This XML file demonstrates configuring XML collection 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.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Root"> <xml-root-element name="document-root" /> <java-attributes> <xml-element java-attribute="employees" xml-path="employee" /> <xml-element java-attribute="addresses" xml-path="addresses/address" /> </java-attributes> </java-type> <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Employee"> <java-attributes> <xml-element java-attribute="workAddresses" xml-path="contact-info/work-address-id/text()" xml-idref="true"> <xml-access-methods get-method="getWorkAddresses" set-method="setWorkAddresses" /> </xml-element> </java-attributes> </java-type> <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.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 |
---|---|---|