In this tutorial will see how to create the entity classes from db schema.

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

steps to download and install Hibernate Tools

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

go to perspective and select database development as below screen shot

 

  • Click on new profile

  • Selecting the database type from Popup

  • Next select the drivers in

  • Eclipse will show predefined drivers version, If your mysql drivers in list then select the respective drivers configuration and upload the respective drivers jar from JAR List tab as below. if your mysql version is not in list then upload downloaded drivers jar from JAR List tab

  • Click in Add Jars/ZIP button to browse the drivers jar file
  • After uploading the drivers jar you can see as above screen shot
  • 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 user name
  • for drivers class click browse button as shown below

  • Click blue dots button to add drivers class file

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

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

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

Now Step 2 Creating JPA project 

  • Change Perspective to JPA 

  • Create new JPA Project as below steps

  • Select JPA Project under JPA folder
  • Use settings as above screen shot
  • Select the hibernate (JPA 2.1)

  • select connection which we created in step 1

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

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

  • Click on generate entities from tables

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

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

 

 

Happy programming

Leave a Reply

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