How to Generate HBM(Hibernate Mapping) files and POJO (Model) Classes in Eclipse

How to Generate HBM (Hibernate Mapping) files(.hbm.xml), Configuration file(hibernate.cfg.xml) and POJO Classes in Eclipse. Please follow...

Required.
1. Eclipse IDE with Hibernate Tool/Plugin.
       -->To see Here how to install Hibernate Tool in Eclipse IDE.
2. Oracle 9i (I am using Oracle 9i Express Edition) or Any.

Steps.

1. Create Java Project with package in Eclipse IDE.

2. Open Hibernate Prospective Windows->Open Prospective->Others->Hibernate.

3. Come to Hibernate Configuration right click add Configuration or Edit Configuration.





4. In add Configuration or Edit Configuration  browse and select project ,select Oracle Database Connection. If you have select it otherwise select New follow following Screen Shots


Select Oracle or Your Using Database.


Select arrow mark option to select database jar file for configuration.
and fill all properties in following.



      Click on Test Connection if Ping Success click on Finish otherwise verify configuration.

5. After select created Database setup Configuration file. It will ask Create New or Use Existing.
    if you have select otherwise Create. And following Screen Shots


write Configuration file name.


Write Session Factory Name and Select Set values from Connection.


Select your created Database.


Final CFG.XML configuration.



6. Go to Option Select Dialect and set Class Path in User Entries to Hibernate JAR file.


7. Click on Apply and OK. And see your tables.

8. Now Click on  Hibernate Code Generation Configuration .





Select output folder and click on Reverse Engineering from JDBC Connection
and follow screen shots.

reveng.xml setup is used to select specific table from Database


select Create New or Use Exist if you hava .reveng.xml







select Export types select generated type you want. Finally click on Run.


9. Finally generate All HBM files and Pojo Classes to Database tables. 

Tags:

Subscribe

© 2014 Java Frameworks. All rights reserved.
Designed by Blogger