EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.oxm.annotations
Annotation Type XmlKey


@Target(value={METHOD,FIELD})
@Retention(value=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:
XmlJoinNode, XmlJoinNodes


EclipseLink 2.4.2, build 'v20130514-5956486' API Reference