I have an object graph in which a circle is involved. How can I handle it? I tried to use the child in the classroom using the @xml transient annotation but JAXB Marshler still detects the cycle.
@Entity @xll root element folk class contacts {@Id Private Long Contact ID; @OneToMany (mapped = "contact") private list & lt; Contact Address & gt; Addresses; ...} @Entity @ XMLRoot Element Folk Class Contact Attender {@Id Private Long Contact IDEd; @ManyToOne @JoinColumn (name = "contact_id") Private contact contacts; Private string address; The good thing about using JAXB is that it is a standard runtime .... With multiple implementations (like JPA). If you use EclipseLink JAASB (MOCA), you have many extensions available to handle JPA entities with bi-directional relationships, using this MOXy @ XmlInverseReference annotation It works on Martial @ XML Transience as well and populates the source relationship with the goal of unsocial. @Entity @XmlRootElement public class contacts {@ id personal long contact ID; @OneToMany (mapped = "contact") private list & lt; Contact Address & gt; Addresses; ...} @Entity @ XMLRoot Element Folk Class Contact Attender {@Id Private Long Contact IDEd; @ManyToOne @JoinColumn (name = "contact_id") @ XmlInverseReference (mapped = "addresses") Private contact contacts; Private string address; ...}
Other extensions are available, including support for composite keys & amp; Embedded key class.
To specify EcliseLink MOXy JAXB implementation, you need to include a jaxb.properties file in your model class (or contract) with the following entry:
Javax.xml.bind.context.factory = org.eclipse.persistence.jaxb.JAXBContextFactory
Comments
Post a Comment