Sunday, January 8, 2012

Hibernate configuration

1) create data base and tables (our user), i am using mysql and Navicat for tables creating and editing



2) set up web application and put these files shown in image (download them) inside lib file

3) create bean map it will data base table and map getters (of attributes) with table columns.Note that inside bean number of attributes should same as in database table.map primary key with @Id and if  it is also auto increment the use this annotation  @GeneratedValue too 



4) inside you src package make a file with name hibernate.cfg.xml and write connection details inside it,see the image bellow
5) write a class to create hibernate session (annotation base), HibernateUtil  class is bellow, represent package and bean classes in it.

7) this is class where I am populating data in user bean and saving it in database.                          


this is simple tutorial for annotation base configuration .Hibernate 3

No comments:

Post a Comment