This document describes how to create a Hibernate Configuration File using NetBeans 6.1

After creating a project, right click on it and select New - other - Hibernate - Hibernate Configuration File as shown in the image below.


Selecting the Hibernate Configuration File type shows a brief description about it in the Description panel.

After selecting Hibernate Configuration File, press next button to bring up another wizard as shown below.


This wizard contains

  • File name, the name of the configuration file. Here empty and uniqueness of the file are checked.
            I.e, if the file already exists or the name of the file is empty then an error message will be
            shown at the bottom of the wizard panel.
  • Project, is a read only field, under which you want to create the configuration file.
  • Folder, by default set to src/java. But you can change the target folder by clicking the Browse button next to the text
            field to change the folder.
  • Created File, is a read only field, shows the location of the file.

Now press Next Button to select the data source..


This wizard contains

  • Session Name, by default sets to session1. But the user can change it.
  • Database Connection, is a drop down with a set of pre-configured database connections. User can pick one or
                      can create a new Database Connection by choosing the last item in the drop down.
  • Database Dialect, gets filled automatically when the user selects a database connection. Its a read only text field.

After pressing the Finish button, a configuration file is created and placed under src/java.

The contents of the newly created Configuration file look as shown below:

  <session-factory name="session1">
    <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
    <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
    <property name="hibernate.connection.url">jdbc:derby://localhost:1527/travel</property>
    <property name="hibernate.connection.username">travel</property>
    <property name="hibernate.connection.password">travel</property>

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo