Creating Entity Classes from Database Schema Using Eclipse: In this tutorial will see how to generate  entity classes from DB schema.

below are the required software’s to be installed in your local machine.

Steps to download and install Hibernate Tools

After installation of hibernate tools follow below steps for creating an entity class

Go to perspective and select database development as below screenshot

  • Click on the new profile

  • Selecting the database type from Popup

  • Next, select the drivers in

  • The eclipse will show predefined drivers version If your MySQL drivers in the list then select the respective driver’s configuration and upload the respective driver’s jar from the JAR List tab as below. if your MySQL version is not in the list then upload downloaded drivers jar from JAR List tab.

  • Click in Add Jars/ZIP button to browse the driver’s jar file
  • After uploading the driver’s jar you can see as the above screenshot
  • Next, add the DB configuration Setting in Properties Tab

  • In my case, localhost is my database IP address
  • test is my database name
  • root is the user name
  • For drivers class click browse button as shown below

Creating Entity Classes

  • Click blue dots button to add drivers class file

Selecting Drivers

  • Select drivers class as com.mysql.jdbc.Driver, click on ok button
  • you will see the final configuration overview to finish setup as below

Final Connection Settings

  • Provide the password and confirm the database and user name and click on test connection you should see below alert

MySQL Connection Successful

  • Click on the Ok button on popup and click on Finish button
  • you will see the connection details and database schema  in left side Data Source Explorer

Creating Entity Classes from Database Schema

Now Step 2 Creating JPA project 

  • Change Perspective to JPA 

Creating Entity Classes from Database

  • Create a new JPA Project as below steps

Creating Entity Classes

Project Creation Step 2

  • Select JPA Project under JPA folder
    Project Creation Step 3
  • Use settings as the above screenshot
  • Select the hibernate (JPA 2.1)

Creating Entity Classes from Database Schema Using Eclipse

  • Select the connection which we have created in step 1

Project Creation Step 5

Project Creation

  • Click on Finish button you will see the project name in left side Project Explorer

Project Creation Completion

  • Next creating Entities using jpa project
  • Right-click on JPA project to see below options

Entitles Creation Step 1

  • Click on generate entities from tables

Creating Entity Classes from Database Schema Using Eclipse

  • enter the package name to where classes need to create and click on finish

Creating Entity Classes from Database Schema Using Eclipse

  • Respective Entity classes created with respective the tables in the database test
  • copy paste the entity classes into your project folder

Happy programming

Creating Entity Classes from Database Schema Using Eclipse

Leave a Reply

Your email address will not be published. Required fields are marked *