How to get hibernate tools eclipse plugin to generate Hibernate mapping files and create entity from Database?

1) Firstly , Go to window tab > Perspective > Other..> Hibernate.
2) if the Plugin does not exist, go to tab Help > Choose Eclipse Marketplace > find : “Hibernate Tools“,
then choose the result – “jboss tool 4.3.0 Final“, then install…


3) If done install, go to window tab again > Perspective > Other..> Hibernate. then Click ok Button.

4) Setup your new Hibernate Configuration
In Hibernate Perspective, right click and select “Add Configuration…

5) In “Edit Configuration” dialog box, click browse to select your project.

6) After that , select for the option – “Database Connection” box, click “New..” button to create your database settings.

– choose mysql DB, then select any Mysql Driver. – if missing jar file, download this jar –mysql-connector-java-5.1.38.jar for

7) In “Configuration File” box, click “Setup” button to create a new or use existing “Hibernate configuration file”,
it will automatic generate file for you. And put in package src\main\resources for the file – hibernate.cfg.xml.



– click Finish
– Apply > OK

8) the result of your hibernate config file – hibernate.cfg.xml.

9) generate the Hibernate mapping files and annotation codes.

10) Create a new configuration, select your “console configuration” , puts your “Output directory” and checked option “Reverse engineer from JDBC Connection“.
11) In “Exporter” tab, select what you want to generate, Model , mapping file (hbm) , DAO, annotation code and etc.


  • Please select option “use Java 5 syntax”.

10) Then it will automatically generate the entity class and hbm.xml


11) then check the hibernate.cfg.xml, which we should add the mapping for stock.hbm.xml.

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE hibernate-configuration PUBLIC
“-//Hibernate/Hibernate Configuration DTD 3.0//EN””&gt;
<property name=”hibernate.connection.driver_class”>com.mysql.jdbc.Driver</property>
<property name=”hibernate.connection.password”>P@ssw0rd</property>
<property name=”hibernate.connection.url”>jdbc:mysql://localhost:3306/hibernate</property>
<property name=”hibernate.connection.username”>root</property>
<property name=”hibernate.dialect”>org.hibernate.dialect.MySQLDialect</property>
<property name=”show_sql”>true</property>
<mapping resource=”com/fndong/common/Stock.hbm.xml”></mapping>


11) What is the <property name=”show_sql“>true</property> for ?

  • answer: Enable the logging of all the generated SQL statements to the console

12) More info from other’s site:

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s