Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340223

Summary: Use of XmlJoinNode should not require accompanying XmlID annotation
Product: z_Archived Reporter: Rick Barkhouse <rick.barkhouse>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matt.macivor
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed fix and modified test none

Description Rick Barkhouse CLA 2011-03-16 15:00:44 EDT
When trying to create a JAXB Context using the class below:

public class Employee {
    @XmlID
    @XmlAttribute
    public Integer id;

    @XmlKey
    @XmlAttribute
    public String name;

    @XmlJoinNodes( {
            @XmlJoinNode(xmlPath = "manager/@id", referencedXmlPath = "@id"),
            @XmlJoinNode(xmlPath = "manager/@name", referencedXmlPath = "@name") })
    public Employee manager;

    @XmlJoinNodes( {
        @XmlJoinNode(xmlPath = "report/@id", referencedXmlPath = "@id"),
        @XmlJoinNode(xmlPath = "report/@name", referencedXmlPath = "@name") })
    public List<Employee> reports = new ArrayList<Employee>();
}

EclipseLink throws the following exception:

Exception Description: Property [manager] in class [documentation.Employee] has an XmlJoinNode declaration with referencedXmlPath [@id], but there is no XmlID or XmlKey property on the target class [documentation.Employee] with the XmlPath [@id].  It is required that there is an XmlID/XmlKey property with a matching XmlPath on the target class for each referencedXmlPath.

Adding a redundant @XmlPath annotation solves the problem but the user should not be forced to do this, because the XPath is implied by using @XmlAttribute.
Comment 1 Rick Barkhouse CLA 2011-03-16 16:01:11 EDT
This problem exists when using both annotations and OXM.
Comment 2 Rick Barkhouse CLA 2011-03-16 16:02:30 EDT
Correction: This problem exists when using *either* annotations or OXM.
Comment 3 Matt MacIvor CLA 2011-05-13 12:26:48 EDT
Created attachment 195606 [details]
proposed fix and modified test
Comment 4 Matt MacIvor CLA 2011-05-13 14:00:15 EDT
Attached patch checked in to SVN
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:16:23 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:27:58 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink