users@jaxb.java.net

Re: Jaxb/hibernate with ManyToOne

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Sat, 15 Dec 2007 11:50:44 +0100

Hi.

> If I have a hibernate mapping where a class has a ManyToOne bidirectional
> relationship, how do I avoid an Infinite recursion?

Use @XmlID/_at_XmlIDREF

> Secondly is there an annotation so that I can marshall/unmarshall either
> object to include the parent child relationship only once?
>
>
> So if I have
>
> class A {
> List<B> children
> }
> class B {
> A parent
> }
>
> Is it possible to un/marshal B and have give me A, which has it's children
> set, or un/marshal A and have B's parent set?

Yes, provide an afterUnmarshal callback and set the parent there.

See this: https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html

You may be also interested to check https://hyperjaxb3.dev.java.net

Bye.
/lexi