Annotation Type XmlKey


@Target({METHOD,FIELD}) @Retention(RUNTIME) public @interface XmlKey

XmlKey is used to mark a property as a key, to be referenced using a key-based mapping via XmlJoinNode. This is similar to the XmlID annotation, but doesn't require the property be bound to the schema type ID. XmlKey is typically used in the composite key use case, since only 1 property can be annotated with the XmlID annotation.

Example:

 @XmlRootElement
 @XmlAccessorType(XmlAccessType.FIELD)
 public class Employee {

     @XmlKey
     public String id;

     @XmlKey
     public String department;

     @XmlJoinNodes({
         @XmlJoinNode(xmlPath="manager/id/text()", referencedXmlPath="id/text()"),
         @XmlJoinNode(xmlPath="manager/dept/text()", referencedXmlPath="department/text()")
     })
     public Employee manager;
 }
 
See Also: