Thursday, July 28, 2011

HIBERNATE - Creating configurations using Eclipse Hibernate Tool

Hibernate Configuration

The following steps takes you through the steps on creating an hibernate configuration easily using the Eclipse Plug-in.

1. Switch to Hibernate Perspective. Window->Open Perspective->Other->Hibernate

2. Right click on Hibernate Configurations tab and click on Add Configurations.

Add Configuration
3. In the new wizard, click on the Setup button on the Configuration file panel. This would ask for creating a new configuration or use an existing configuration.

Click on Setup to create configuration file
4. Proceed by click on Create new.

Create New Configurations
5. Select the location where the hibernate.cfg.xml file has to be created.

Location for storing hibernate.cfg.xml
6. Create the configuration based on your database. Here I am using MYSQL as my Database.

Configure the hibernate.cfg.xml based on database needs
7. Once the configuration file is created, go to the classpath tab and select the project that has to be used to refer the class files for this configuration. This classpath would be useful in using Hibernate Editors.

Classpath configurations

8. Click on Finish. Now you should be able to see the tables under the database that you have connected.

Databases and tables under Hibernate Configurations
NOTE: To use the HQL Editor and write queries, you need to create the HBM files and the corresponding POJO classes.

No comments:

Post a Comment