• Post Reply Bookmark Topic Watch Topic
  • New Topic

[newbie] xsd to Jaxb to JPA using EclipseLink

 
Shawn Sebedang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys. A newbie question:

I am a fresh graduate and currently studying for an upcoming project. The task is convert a set of XSD docs through JAXB to corresponding Java specs. Also generate the correct SQL table definitions. So the topics I am studying now are JAXB and JPA, decided I will be using eclipseLink and I have it all set up. What I don't understand is the workflow. From what I understood, it's
xsd -> jaxb classes -> annotate(JPA) -> database
I can now generate JAXB classes from an example XSD but I don't know what to do from there. I have read about generating JPA classes from a database but I don't have any resources on doing the reverse. Help would be appreciated


 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can persist the same JAXB generated class through JPA by adding @Entity and @Id annotations to them.
You can auto create a database schema using DDL generation in your JPA persistence.xml,

see,

http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_ddl_generation.htm#BABHEJJI

Normally it is better to design an object mode, then map it to XML and the database using JAXB and JPA annotations.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!