Configuration of Hibernate in MyEclipse

Step by Step produce to Use hibernate in our project:
  • You have to include these jars in your project lib folder :
    hibernate3.jar and hibernate-validator.jar

  • Then go to windows and choose show view for DB browser

    Then this perspective will be opened.

  • Now go for Making connection with database:

  • After click on new ,this view should be opened

    Here you to write any profile name and select MYSQL Connector/J and go for configuration of database driver

  • After completion of configuration this window will appear

    Here you have to write password same as MYSQl and click on finish button.
  • Now after getting connection the DB Browser Will appear as

    Then right click on any table and select option as “Hibernate Reverse Engineering”

  • After that right click on your project->MyEclipse->Add Hibernate Capabilities and goes as

    Now, complete configurations part is done and it auto generates hibernate.cfg.xml, TableName.hbm.xml and Table pojo Class

After that, to use in your class you have to go through these easy steps:

public static void main(String[] args) {
		Configuration cfg=new Configuration();
		cfg.configure();     -------configuring cfg file
		SessionFactory sf=cfg.buildSessionFactory();
		Session session=sf.openSession();
             Transaction trans=session.beginTransaction();
             //Any Operation to be performed