5

I'm trying to find a way to accomplish a xsd schema to datastore roundtrip, with minimum effort.

I used jaxb to build my object model from schemas, now I would like to store these objects based on JPA (or JDO or something else?). Is it possible, to auto enhance the objects with the missing annotations based on the JAXB Annotations? Is it desirable?

Thanks

joecks
  • 4,539
  • 37
  • 48

2 Answers2

4

You have several options for this use case.

Option #1 - Hyperjaxb3

I have not used this myself, but Hyperjaxb3 is supposed to generate both JAXB and JPA annotations on the model:

Option #2 - Use Dali to map your POJOs to Database (JPA)

The Eclipse Dali tool provides tooling to easily map your POJOs to a relational database using JPA:

Option #3 - Use EclipseLink

EclipseLink provides both JPA and JAXB implementations. The JAXB implementation (MOXy) contains extensions specifically for handling JPA entities:

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • Hyperjaxb3 sounds good, especially for the maven plug-in, I will try it. – joecks Nov 05 '10 at 10:15
  • 1
    HyperJaxb3 did not work out for me, since it uses the jpa 1.0 standart, and misses some annotations. I will try EclipseLink next time. – joecks Nov 16 '10 at 16:00
  • JPA 2.0 will be supported in the next version of Hyperjaxb3 (0.5.6). – lexicore Jan 24 '11 at 14:02
  • Hyperjaxb3 (0.5.6) does not seem to support bi-directional JPA relationships. If you need such relationships, you need MOXy or something else. – Nick Jan 06 '14 at 14:00
0

Use DataNucleus and you can persist via JDO or JPA and internally it uses JAXB. http://www.datanucleus.org

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
  • How can it be done via datanucleus, I thought datanucleus is just a persistence framework, any example? – joecks Nov 05 '10 at 09:22
  • DataNucleus can persist/retrieve data for many types of datastore, be that RDBMS, XML, or many others. You could have data in XML and retrieve it, persist it to RDBMS, etc. You can use JPA/JDO XML/annotations solely or (when storing data in XML) use a mix of JPA/JDO and JAXB. Depends what you mean by "datastore", and what exactly you want to do - the question is not precise. – DataNucleus Nov 05 '10 at 09:42
  • I meant by datastore, a server-side store abstracted via JPA/JDO (probably RDBMS) and I use XML messages for communication with the server. I started to build the model for communication from XML Schemas and now I would like to maintain this single model also for persistency. But if I understood you right persisting data to XML is done with JAXB annotations. But I need the XML messages for communication, hence in this case the clients would be the data-store of my data, which is an interesting idea, speaking of distributed data-storage but unfeasible for my project :) – joecks Nov 05 '10 at 10:33