Annotation Type XmlInverseReference


@Target({FIELD,METHOD}) @Retention(RUNTIME) public @interface XmlInverseReference
This annotation is used to map a back-pointer during the unmarshal operation. When configuring an @XmlInverseReference, the "mappedBy" attribute must be set to the field on the reference class that maps to this field. For example:

 @XmlRootElement
 public class Employee {
    ...
    @XmlElementWrapper(name="phone-numbers")
    @XmlElement(name="number")
    public List<PhoneNumber> phoneNumbers;
    ...
 }

 public class PhoneNumber {
    ...
    @XmlInverseReference(mappedBy="phoneNumbers")
    public Employee owningEmployee;
    ...
 }

By default using @XmlInverseReference will make the property act the same as @XmlTransient for the marshal operation. You can make the property writeable by combining it will @XmlElement.

 public class PhoneNumber {
    ...
    @XmlInverseReference(mappedBy="phoneNumbers")
    @XmlElement
    public Employee owningEmployee;
    ...
 }
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Element Details