Managing Hibernate Entity Relationships

One of the most important pieces of Workshop is the ability to view, create, and manage Hibernate entity relationships. The Entities Editor provides a centralized view of all entity relationships, allows for modification of entity properties, and simple navigation between the object model, Hibernate mapping, and database schema layers.

As the web application evolves, pages, business logic classes, and entity relationships often must be updated to meet the new specification. It is at this point that many times errors are introduced into the application but, through AppXRay, Workshop validates the changes, even at the ORM level, to ensure that these dependency relationships remain consistent.

Managing Entity Relationships in the Entities Editor

The Entity Editor serves as the focal point for viewing, managing, and traversing through the entity relationships defined in the project.

  1. From within the AppXplorer expand the Hibernate Configuration branch. All entities specified in the Hibernate configuration are available under the Entities branch. To access all of the entities and their properties, double-click on the Entities Editor.
  2. The Hibernate Entities Editor displays all entity relationships defined in the web application. Each box displays a specific entity, its properties, and an icon denoting the nature of the relationship. Notice that as an entity is selected, the Smart Editor displays the properties as defined in the Hibernate mapping file. The Smart Editor provides an easy access point to modify Hibernate mapping file properties, update the associated Java Bean, and access database schema information.
  3. Selecting a property highlights its relationship with other OR mappings and provides tooltip information of its properties. Once again, the Smart Editor provides a convenient interface into the Hibernate mapping file and associated object model.
  4. In addtion to providing management for current Hibernate Entities, the Entities editor links in to the other features of Workshop including the OR Mapping wizards using either schema reverse engineering (bottom up) and object model mapping (top down). In addition, Workshop can generate SQL DDL files based on the entity relationships outlined in the Entities Editor.

Adding New Properties to an Existing Entity

In addition to providing a view of the entity relationships for a project, and a simple mechanism to update configuration of existing entities, the Hibernate Entities Editor provides wizards to assist in defining new properties for a specific entity.

  1. Right click and select New Property to define a new property for an existing entity.
  2. In the Property Tag dialog configure the new mapping property and click Ok. Workshop will add the new code to the mapping file and update the Entities Editor to reflect the new content. If a connection to the database has been established, Workshop provides code completion for the database artifacts such the column name.

Navigating to the Hibernate Mapping Source

The Hibernate Entities Editor also allows for easy navigation to the specific mapping definitions.

  1. Right-click an entity and select Open Mapping Source to navigate to the Hibernate mapping file for that entity.
  2. Workshop includes form editors for the Hibernate mapping configuration file which organizes mapping properties, provides forms to manage current properties, and includes wizards to assist in the creation of new content. In the example below, the Mapping Class includes hyperlinks to the Java Bean and database schema (DbXaminer).
  3. While managing the entity relationships, AppXRay analyzes the dependencies between the related ORM layers and provides validation and code completion (use CTRL + SPACE). In the example below, the cursor is placed at the column attribute and code completion displays the available columns as defined in database schema.

Related concepts

Generating Object Relational Mappings


Still need help? Post a question on the Workshop newsgroup.