| Summary: | JAXB Externalized Metadata: xml-idref not working with xml-elements | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | David McCann <david.mccann> | ||||
| Component: | Eclipselink | Assignee: | Matt MacIvor <matt.macivor> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 317962, 323986 | ||||||
| Attachments: |
|
||||||
Created attachment 182211 [details]
proposed fix and test case
Proposed fix checked into SVN Reviewed by Blaise Doughan and David McCann The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Given the following object model: public class Root { public Bar bar; public List<Address> addresses; public List<Phone> phoneNumbers; } public class Bar { public List items; } public class Address { public String id; public String street; public String location; } public class Phone { public String id; public String number; public String location; } And the following eclipselink-oxm.xml file: <?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"> <java-attributes> <xml-element java-attribute="bar" /> <xml-element java-attribute="addresses" xml-path="address" /> <xml-element java-attribute="phoneNumbers" xml-path="phone" /> </java-attributes> </java-type> <java-type name="org.example.Bar"> <java-attributes> <xml-elements java-attribute="items" xml-idref="true"> <xml-element java-attribute="address" xml-path="address/@id" type="org.example.Address"/> <xml-element java-attribute="phone" xml-path="phone/@id" type="org.example.Phone" /> <xml-element-wrapper name="contact" /> </xml-elements> </java-attributes> </java-type> <java-type name="org.example.Address"> <java-attributes> <xml-element java-attribute="id" xml-id="true" /> </java-attributes> </java-type> <java-type name="org.example.Phone"> <java-attributes> <xml-element java-attribute="id" xml-id="true" /> </java-attributes> </java-type> </java-types> </xml-bindings> When unmarshalling the following instance document: <?xml version="1.0" encoding="UTF-8"?> <root> <bar> <contact> <phone id="2" /> <address id="3" /> <phone id="1" /> </contact> </bar> <address> <id>1</id> <street>Anystreet Rd.</street> <location>Kanata</location> </address> <address> <id>2</id> <street>Somestreet Ave.</street> <location>Montreal</location> </address> <address> <id>3</id> <street>Nowhere Street</street> <location>Almonte</location> </address> <phone> <id>1</id> <number>617.288.4636</number> <location>Ottawa</location> </phone> <phone> <id>2</id> <number>617.858.4636</number> <location>West Carleton</location> </phone> <phone> <id>3</id> <number>617.555.4636</number> <location>Unknown</location> </phone> </root> We would expect to get a Root object with 1 Bar, 3 Addresses and 3 Phones. Most important we'd expect that the Bar object would contain 3 entries in its 'items' list: - Phone (id=2, number=617.858.4636, location=West Carleton) - Address (id=3, street=Nowhere Street, location=Almonte) - Phone (id=1, number=617.288.4636, location=Ottawa) This is not the case, however. The Bar object has 2 Phone and 1 Address entries, but non of their property values are populated (they are all null). In MappingsGenerator we don't check for XmlIDREF when constructing our Choice mapping, but should. Currently Choice mappings only support direct/composite and directcollection/compositecollection. We will need to include object/collection reference mappings as well.