JAXB 映射对 XML 的循环引用
2022-09-02 12:12:23
我有一个包含循环的对象图。如何让 JAXB 来处理这个问题?我尝试在子类中使用注释,但 JAXB 编组器仍能检测到该循环。@XmlTransient
@Entity
@XmlRootElement
public class Contact {
@Id
private Long contactId;
@OneToMany(mappedBy = "contact")
private List<ContactAddress> addresses;
...
}
@Entity
@XmlRootElement
public class ContactAddress {
@Id
private Long contactAddressId;
@ManyToOne
@JoinColumn(name = "contact_id")
private Contact contact;
private String address;
...
}