JAXB Mapping cyclic references to XML

This page in the “Unofficial JAXB Guide” offers three strategies for dealing with cycles. They are (in summary):

  • Mark one of the reference attributes that form the cycle as @XmlTransient.
  • Use @XmlID and @XmlIDREF so that the references are represented using XML ids arather than by containment.
  • Use the CycleRecoverable interface to deal with cycles programmatically.

Leave a Comment