I'm using a mix of JAXB, JPA, and a RESTful web service to pass objects across the wire. My domain objects contain a mix of JPA and JAXB annotations, and I'm able to successfully unmarshall my domain objects using Spring's RestTemplate with a minimum amount of code. I remember reading something not too long ago (may have been an answer on SO, may have been a blog) where the author argued that he would never rely on annotations in a production environment, but always marshall and unmarshall according to a schema. Is this still a necessary practice?
If I have a .jar with annotated beans that is a dependency in two projects (e.g. the producing RESTful web service and the consuming client), wouldn't introducing generated XSDs effectively add another set of data requiring maintenance? When using annotated JAXB POJOs, when are schemas necessary and what benefit do they provide?
JAXB represents its metadata as annotations so there really is no marshal/unmarshal according to the XML schema.
I lead the JAXB component (MOXy) of EclipseLink, which is best know for its JPA implementation. My recommendation for developers is to use a combination of JAXB & JPA annotations on their model.
Uses of XML schema:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With