Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] roundtripping POJOs via MOXy

Hi, Blaise:

Thanks for the helpful pointer (and blog).  XmlAdapter works for both
denormalization
and bidirectional referencing.

The adapter for one side of the bidirectional referencing works as in
your helpful example.

FWIW, the adapter for the back reference accumulates a list of ids so
the back references
can be resolved after their target objects have been unmarshalled.


Erik Hennum


On Mon, Oct 29, 2012 at 8:23 AM, Blaise Doughan
<blaise.doughan@xxxxxxxxxx> wrote:
> Hi Eric,
>
> From your example you appear to have a foreign key in one document that
> references a primary key in another document.  If this is indeed your use
> case then you may find the following example helpful:
>
> http://stackoverflow.com/questions/5319024/using-jaxb-to-cross-reference-xmlids-from-two-xml-files/5327425#5327425
>
> -Blaise
>
>
> On 12-10-26 1:14 PM, Erik Hennum wrote:
>
> Hi, MOXy Mavens:
>
> Given a graph of POJOs with bidirectional relationships, what's the
> best strategy
> for using MOXy to marshall trees out of the graph as XML and, later or
> elsewhere,
> unmarshall the XML and merge it into a new graph?
>
> The graph contains bi-directional one-to-many relationships between the
> POJOs.
>
> Ideally, the marshalled XML would have an id (unique for the class) as well
> as a
> few denormalized fields from each related object.  The denormalized fields
> would be thrown away on merge.
>
> The strategy has to be generic (ie, not coded to a specific set of POJOs).
>
> I did take a look at:
> http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA/Relationships
>
> I can use @XmlInverseReference() to embed a related object.  When I merge
> new
> related objects, the object with the nested object gets a reference.
> However, the
> nested object doesn't get the inverse reference.
>
> Also, I can use @XmlID / @XmlIDREF to embed ids for references.  However,
> I can't unmarshall the generated XML.
>
> Any suggestions on how best to leverage MOXy for this problem?
>


Back to the top