This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Convert Hibernate hbm.xml file (or existing database) to JPA annotated classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Convert Hibernate hbm.xml file (or existing database) to JPA annotated classes" Watch "Convert Hibernate hbm.xml file (or existing database) to JPA annotated classes" New topic
Author

Convert Hibernate hbm.xml file (or existing database) to JPA annotated classes

Scott Seto
Greenhorn

Joined: Sep 08, 2011
Posts: 6
Hi,

How can I convert an hbm.xml file to JPA annotated classes
using just a simple function call from inside my Java code?
Is there a function or functions in the Hibernate or JPA library that
would help me?

Also, is there an open source tool to convert an existing database into JPA annotated classes?

Thanks.

- Scott
Scott Seto
Greenhorn

Joined: Sep 08, 2011
Posts: 6
I did some research and found that I could do the conversion from the hbm.xml file to
the annotated classes in two steps.

The first step would be to use the org.hibernate.tool.hbm2ddl.SchemaExport
class in Hibernate to create the database tables.

Then use the Hibernate Pojo Generator found at:
http://hibernatepojoge.sourceforge.net/
to convert from the database tables to the annotated classes.
Using the source code, I could pick and choose the functions that I want to use.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert Hibernate hbm.xml file (or existing database) to JPA annotated classes
 
Similar Threads
Mixing Hibernate Annotations with .hbm files
Tools to generate the domain model diagram
creating .hbm.xml file
QuerySyntaxException: "Tablename is not mapped"
JPA + Stored Procedure