Step 8. Manage Hibernate Configuration File with Hibernate Configuration Editor

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

  1. 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.


  2. 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 .


  3. 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.

  4. Click Next.
  5. 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.)

  6. 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.

  7. Save the hibernate.cfg.xml file.

To Specify the Mapping Properties (Optional)

  1. Click the Mappings tab in the Hibernate Configuration editor.
  2. 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.

  3. 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.

  1. Click the Properties tab in Hibernate Configuration editor.
  2. Selecting a configuration property will display the Configuration Property name and value, allowing you to edit them.

  3. 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.

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

  5. Click OK
  6. Save the hibernate.cfg.xml file.

To Understand Validation and Code Completion (Optional)

The Hibernate Configurations Editor also supports validation and code completion.

  1. 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.

  2. 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.
  3. Save the hibernate.cfg.xml file.
  4. 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.

  5. 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.