Thursday, May 19, 2011

how to make Entity classes using Hibernate mapping file and POJO from Database?

How to make entity classes using hibernate mapping file and POJO from Database.

Step by step way is given below.
using net beans you can done it easily

With NetBeans.

assuming that we created a new project named 'HBN_Test'.

then add hibernate and spring framework file to our project.


Making hibernate configuration wizard file

then we need to configure hibernate configuration file in to our program


1.Right click the project then in the 'new' option select
hibernate configuration wizard option.it will open a new window.
2.Then click next and select appropriate database connection and
and we can see that database dialect is
'org.hibernate.dialect.MySQLDialect'
3.click finish button
this fill connect hibernate with our database
then


Making hibernate reverse engineering wizard file


1.Right click the project then in the 'new' option select
hibernate reverse engineering wizard option.it will open a new window
2.click next then we can see the tables in our data base select wanted tables check if we want to include related tables(forigen key referance tables)
3.click finish button.

this fill connect hibernate with our selected tables
then


Making hibernate mapping file and pojo from database



1.Right click the project then in the 'new' option select
hibernate mapping file and pojo from database option.it will open a new window
2.select our hibernate configuration file(hibernate.cfg.xml) and also hibernate reverse engineering wizard(hibernate.reveng.xml)
3.In general setting section select jdk 5 language features and EJB 3
annotation if we want.
4.then select appropriate package to import our entity classes.
5.then click finish button.
6.this will makes entity classes for our tables in the database.

No comments:

Post a Comment