title: Why does JAXB sometimes map to JAXBElement?
body: <p>There is a placeholder answer over at <a href="https://jaxb.dev.java.net/guide/Mapping_of__xs_element____to_JAXBElement.html" rel="noreferrer">the unofficial guide</a> with a link to an article which (to me) seems quite unrelated.</p>
  
  <p>I use XJC to generate my JAXB classes and while most of them map to each other as expected, some elements get mapped to <code>JAXBElement&lt;Foo&gt;</code>. This is most annoying for graphs with cycles, where sometimes the parent node of a Foo element will be the <code>JAXBElement&lt;Foo&gt;</code>, which doesn't itself have a parent property, breaking the cycle.</p>
  
  <p>I can think of various workarounds, but it would be much nicer if someone could explain this behaviour to me. Why does JAXB sometimes map a <code>&lt;Foo&gt;</code> element to <code>JAXBElement&lt;Foo&gt;</code> instead of Foo?</p>