title: JAXB Mapping cyclic references to XML
body: <p>I have an object graph that contains a cycle.  How do I get JAXB to handle this?  I tried using the <code>@XmlTransient</code> annotation in the child class but the JAXB marshaller still detects the cycle.</p>
  
  <pre><code>@Entity
  @XmlRootElement
  public class Contact {
  
      @Id
      private Long contactId;
  
      @OneToMany(mappedBy = "contact")
      private List&lt;ContactAddress&gt; addresses;
  
  ...
  
  }
  
  @Entity
  @XmlRootElement
  public class ContactAddress {
  
      @Id
      private Long contactAddressId;
  
      @ManyToOne
      @JoinColumn(name = "contact_id")
      private Contact contact;
  
      private String address;
  
  ...
  
  }
  </code></pre>