Creating the Hibernate Configuration File

See Also

To use Hibernate your application must have a Hibernate configuration file that contains the database connection details enabling the application to connect to a database. The file also contains information about the location of Hibernate mapping files. You can edit this file if you need to change the database connection details. You can have multiple Hibernate configuration files, but the default name for the configuration file used by Hibernate is hibernate.cfg.xml.

A Hibernate configuration file is created automatically if you create a web application and you select the Hibernate framework in the New Project wizard.

You can also create a Hibernate configuration file using the New File wizard if you want to use Hibernate in your application, for example in a Java SE application.

To create hibernate.cfg.xml using the New File wizard:

  1. Open the New File wizard.
  2. Select Hibernate from the Categories list and Hibernate Configuration File from the File Types list. Click Next.
  3. Type hibernate.cfg for the name and specify a location. Click Next.
  4. Select a Database Connection from the drop down list. Click Finish.

When you click Finish, the file hibernate.cfg.xml is created in the location you specified and the file opens in the Source Editor. If you did not specify a location the file is created in a source package with the name <default package>. The wizard also adds the Hibernate library to the classpath if it has not already been added.

See Also
About Hibernate Support
Editing the Hibernate Configuration File
Creating Hibernate Mapping Files
Adding Hibernate Support to a Project

Legal Notices