Previous Next vertical dots separating previous/next from contents/index/pdf

9. Manage Hibernate configuration file with Hibernate Configuration Editor

BEA Workshop Studio 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.

9.1. Specify the Connection properties

  1. From within the AppXplorer, 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.

  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 used by Hibernate to obtain JDBC connections.

  4. Click Next.
  5. We have specified the connection parameters during creating a new connection. In Connection Properties dialog, select the dialect (HypesonicSQL) for the Hypersonic database and click Next. 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.

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

  7. Save the hibernate.cfg.xml file.

9.2. Specify the Mapping properties

  1. Click the Mappings tab in Hibernate Configuration editor.

  2. Select the hibernate mappings file com/bea/beans/Product.hbm.xml from the list. The workshop displays corresponding Mapping Properties and allows to select another file by clicking the Browse... button or navigate to Product.hbm.xml file by clicking the Mapping File hyperlink.

  3. The editor also allows you to add a new mapping file by clicking the New Mapping button and browse to the Mapping File.

9.3. 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 all the list of Hibernate properties with description.

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

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

9.4. Understand validation and code completion facility

The AppXRay provides validation and code completion facility in Hibernate Configurations Editor.

  1. Switch to the Mappings tab of Hibernate Configurations Editor. Edit the value of resource attribute of mapping element in source editor to com/bea/beans/Customer_NEW.hbm.xml.

  2. As we have specified an invalid mapping file which does not exist either in project or at the specified location, the Editor shows a warning. Reset the value of resource attribute of mapping element in source editor to com/bea/beans/Customer.hbm.xml.
  3. Save the hibernate.cfg.xml file.
  4. Move the cursor to resource attribute of 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 name attribute of 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:

 

Skip navigation bar   Back to Top