Using Hibernate Synchronizer Tool in Eclipse
This tool is used to generate hibernate mapping xml directly from database tables. This is a reverse engineering process where in we directly use database tables to generate so called hbm files.
Installing it in eclipse
To use this tool download hibernate synchronizer from following location:download hibernate synchronizer
Extract the zip file to plugins folder of you eclipse .
Then restart your eclipse .
Then go to windows then to preference.
You will see the hibernate synchronizer option at the left highlighted.
Using it in project
Add mysql jdbc jar to the lib folder of your project.
Now right click your project src folder and create a package say com.lara
Next right click lara folder and go to new then other and then hibernate mapping file.
suppose following is the
database server
suppose following is the database configuration in mysql server .
Container : the folder in which hbm xml needs to be gernerated.
Driver : the mysql driver class name.
URL : the url to connect to database . Here test is my database name
Username : mysql username
password : mysql password
Table : select the table to generate Hibernate mapping file .
package : the package name in here is com.lara . This will be specified in hbm file generated
and click Finish.
Your hibernate mapping file will be generated inside lara folder.
Generate pojo classes from the hibernate mapping file
Right click the hbm file (eg user.hbm.xml in this case) then Hibernate synchronizer and then synchronize and overwrite as shown below
In addition two classes will be generate , one named User in your lara folder and the setters and getters in Base User under base folder in lara package.
0 comments:
Post a Comment