I have the following XML structure:
<PriceBook>
<PriceList product="0D000000.007C.06">
<Price .../>
<Price .../>
</PriceList>
...
</PriceBook>
A PriceList
holds a list of Price
objects. I don't want that Price
objects have back references to their PriceList
s.
Question:
I would like to have the product information not only set in my PriceList
objects, but also in the Price
objects. Of course I don't want to have 开发者_运维问答that duplication in the XML itself, only on Java side. What is the most elegant way to do this?
You could leverage an afterUnmarshal
event on the PriceList
object. In this event you could iterate over the list of Price
objects and set the product information. You would need to mark the product information on Price
to be @XmlTransient.
For More Information
- http://wiki.eclipse.org/EclipseLink/UserGuide/MOXy/Runtime/Events
精彩评论