Step 9. Manage Hibernate Configuration File with Hibernate Configuration Editor
BEA Workshop includes form editors to manage the Hibernate configuration file and includes wizards to add new content. In addition, AppXRay provides validation, navigation, and code completion for all Hibernate properties and their dependencies.
The tasks in this step are:
To Specify the Connection Properties
To Specify the Mapping Properties
To Specify the Configuration Properties
To Understand Validation and Code Completion
To Specify the Connection Properties
- From within the AppXplorer view, right-click the Hibernate
Configuration branch and select Open. You can
also open the configuration file by double-clicking the hibernate.cfg.xml file.

The Hibernate Configuration Editor organizes the Hibernate
properties into three main categories; Connection, Mappings and Properties which
is reflected in the tabs at the bottom of the view .

- The Connection tab displays the current connection properties
and the ability to modify the existing connection.
To update the Hibernate
connection information, click the Edit Connection Properties option
and specify the scheme (JDBC database driver) used by Hibernate to obtain
JDBC connections.

- Click Next.
- In the Connection Properties dialog, using the Database
Dialect dropdown, select
HypesonicSQL.
Click Next.
(Note: if you have multiple connections, You can use the Populate
from existing connection link to populate the database connection
properties from a connection defined through the DbXplorer view.)

- In the Connection Pooling dialog, specify the C3P0 pool
properties as shown below and click Finish.
Workshop will
update the Hibernate configuration file source code.

- Save the hibernate.cfg.xml file.

To Specify the Mapping Properties (Optional)
- Click the Mappings tab in the Hibernate Configuration
editor.
- Select the hibernate mappings file com/bea/beans/Product.hbm.xml from
the list. Workshop displays corresponding mapping properties and allows you
to select another file by clicking the Browse button.

- The editor also allows you to add a new mapping file by clicking the New
Mapping button and browsing to the Mapping File.
(Click Cancel on the Mapping Tag dialog.)

To Specify the Configuration Properties
In Hibernate Configurations Editor, the Properties tab displays the current Hibernate configuration properties and their values through the form editor.
- Click the Properties tab in Hibernate Configuration editor.
- Selecting a configuration property will display the Configuration Property name and value, allowing you to edit them.

- To add additional properties, click the New Property button
and specify the Name and Value.
Click the
button
to browse through a list of properties. The Select Property dialog displays
a the list of Hibernate properties with descriptions.

- Select the hibernate.show_sql property and the value true to
enable logging of generated SQL to the console.

- Click OK
- Save the hibernate.cfg.xml file.
To Understand Validation and Code Completion
(Optional)
The Hibernate Configurations Editor also supports validation and code completion.
- Switch to the Mappings tab of Hibernate Configurations
Editor.
Select com/bea/beans/Customer.hbm.xml from the Mapping
Files list.
Edit the value of the resource attribute
of the mapping element
in the source editor to com/bea/beans/Customer_NEW.hbm.xml.

- Because we have specified an invalid mapping file which does not exist
either in the project or at the specified location, the Editor shows a warning.
Reset the value of the resource attribute of the mapping element
in the source editor to com/bea/beans/Customer.hbm.xml.
- Save the hibernate.cfg.xml file.
- Move the cursor to the resource attribute of the mapping element
and press CTRL+SPACE. The code completion feature of AppXRay displays a list
of hibernate mapping files in the project.

- Similarly, move the cursor to the name attribute of the property element
and press CTRL+SPACE. The code completion feature of AppXRay displays a list
of hibernate properties.

Click one of the following arrows to navigate through the tutorial:
Still need help? Post a question on the Workshop
newsgroup.