How to Generate Hibernate Pojo Classes from DB Tables

Download Hibernate Tool and extract content to root folder of Eclipse (should merge plugins and features folders)., Start eclipse. , Click on and create a cfg file., Click on and create a new console configuration., Enter the name of the console...

12 Steps 1 min read Medium

Step-by-Step Guide

  1. Step 1: Download Hibernate Tool and extract content to root folder of Eclipse (should merge plugins and features folders).

    The following properties should be specified : jdbc url , username, password, DB schema, driver class and dialect. , Add the jar file that contains your DB driver in the classpath section at the bottom. , Click Browse button against the Configuration file and select the cfg.xml file created in step
    3. ,, Click on include button and specify the schema and table name(s) to reverse engineer.

    Multiple table names can be specified using sql wild char (eg:
    TBL_%).

    Click Finish. ,,, Also select the Output Directory and a relevant package. , Click run. ,
  2. Step 2: Start eclipse.

  3. Step 3: Click on and create a cfg file.

  4. Step 4: Click on and create a new console configuration.

  5. Step 5: Enter the name of the console configuration.

  6. Step 6: Click on and select the location of the file.

  7. Step 7: Select the cfg.xml file created in step 3 as the Console Configuration.

  8. Step 8: Switch to the Hibernate perspective and Click on the Hibernate icon in the tool bar and select the option.

  9. Step 9: Right click on the tree node and select New.

  10. Step 10: Give the name of the configuration and select the console configuration created in step 5 and reveng.xml created in step6-7.

  11. Step 11: Go to the Exporters tab and check Generate domain code(.java) and Generate mappings (hbm.xml).

  12. Step 12: The hibernate mapping xml files and Java classes will be created in the output directory specified in step 11.

Detailed Guide

The following properties should be specified : jdbc url , username, password, DB schema, driver class and dialect. , Add the jar file that contains your DB driver in the classpath section at the bottom. , Click Browse button against the Configuration file and select the cfg.xml file created in step
3. ,, Click on include button and specify the schema and table name(s) to reverse engineer.

Multiple table names can be specified using sql wild char (eg:
TBL_%).

Click Finish. ,,, Also select the Output Directory and a relevant package. , Click run. ,

About the Author

B

Brittany Wilson

A seasoned expert in lifestyle and practical guides, Brittany Wilson combines 6 years of experience with a passion for teaching. Brittany's guides are known for their clarity and practical value.

71 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: