Sunday, 28 July 2013

 Hibernate reverse engineering eclipse                         tutorial:-

Hello friends,
please gone through all steps if you want to learn reverse hibernate engineering.

This tutorail is about how we use hibernate reverse engineering in eclipse

first you have to download JBoss Tools by eclipse market place or either by install ..




Select one option. Here i selected following option because i am using Eclipse Indigo ::: >>
JBoss Tools 3.3 Development Milestone (requires Eclipse)

Now copy page URL and Goto Help > Install New Software.. paste URL in Work with Textbox as shown in below image.



Create Project Structure as shown in below image:-


Here we i create project with the name RevHibernate
And pacakage com.rev.model 


After that then Add Additional jars:-



1.hibernate3.jar
2.javax.persistence.jar
3.mysql-connector-java-5.1.21-bin.jar


Now open hibernate perspective Goto Window > Open Perspective > Other.. as shown in below image.



After that Select Hibernate to open as perspective:-



Then you also find hibernate at right corner of your eclipse




Now Create Database. Here i use mysql to create database.
My Schema name is revhibernate that contains two tables
1. Employee
2. Company
The image of the tables as shown below
1.Employee Table


add foreign key in employee table as shown in below image.



2.Company Table



Now again switch to hibernate then
Press right click on src folder and create new hibernate.cfg.xml file.










Add folowing properties 

1.src path
2.hibernate configuration file name
3. DB type MySQL
4.select driver from drop down
5. url define port and Db connectivity path
6.username and password as per your db
7. check right and then finish.



Press right click on project folder and create new file in project folder hibernate.reveng.xml as shown in below image.






Perform following activity:-

1. select config
2.include only those table thats you want to generate code
3.click on refresh
4.click on finish button




Now select top most small icon and select Hibernate Code Generation Configuration… as shown in below image.





here is check box for require code..
please select as per your requirment.


After run this the result is here :
hbm file and bean class corresponding the db table is create......




No comments: