Generate the JPA annotated entities from the database tables using hibernate tools

Lets take a look at some graphical step by step procedure to generate java annotated entities from the already available database tables. This can be achieved using Hibernate Tools from JBoss.

Here are some pre-requisites to be taken care of

1. JBOSS Tools eclipse update site
2. Search & Select hibernate tools from the listing
3. Install Hibernate tools
4. Download the hibernate dependencies

Install the Hibernate Tools from the eclipse Install New Software option and go on selecting and accepting the next options:



Lets start by creating a basic JPA project and set it up for magic.

1. Create a new JPA project and add JPA facet configuration

Create e new JPA project 



Select the JPA Facet as Hibernate JPA. Disable JPA configuration


Add a MySQL connection profile and test it for connectivity to your database


Add the MySQL driver and also Select annotated discovery of beans. The final facet page will look like this:



2. Add hibernate dependencies to the build path

Go to the java build path configuration from project properties. Make sure you have downloaded the relevant dependencies and configured it as below.



The final project structure shall look as per the below snapshot




3. I did get a classpath error and I found that I should not be using JPA but core as a Hibernate setting console configuration

Error:  [Classpath]: Could not create JPA based Configuration

Solution: Go to the Hibernate Settings from project properties and select details on your console configurations and set it as per the snapshot here.


4. Generate the entities from the table in your configured database

This is the final step where you generate the java entities by selecting the JPA tools option


Here you have to select the package the generated entities should target along with the console configuration that we already setup before.


As soon as you click Finish here the processing starts and the package should get populated with entities mapped to the tables in the configured database.

We get the generated entity bean here

This is a great help to kickstart your development you wont want to really start writing each annotation and associations manually.

GitHub Link:






One thought on “Generate the JPA annotated entities from the database tables using hibernate tools

  1. mdbikerdude says:

    For those wanting to do this without JBOSS – using the standalone open source CAM Editor (Windows/Mac/LINUX) – with simple drag and drop mapping – see the tutorial here:

    CAM Editor also allows you to design a new database from scratch – then generate both the SQL DLL and Hibernate JPA directly.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s