To generate class diagrams from entity relationship diagrams:
- We first open Project Browser by selecting View > Project Browser from the toolbar.
- Click the New Model button to create a new model.
- Enter the name as Entity Model.
- Now, let's create entity relationship diagram under Entity Model. Right-click on the Entity Model and select Sub Diagrams > New Diagram....
- In the New Diagram popup window, select Database Modeling > Entity Relationship Diagram. Click Ok to confirm.
- Develop the following entity relationship diagram.
- Repeat the above steps to create the following entity relationship diagram under Entity Model.
- Once the entity relationship diagrams are ready, we can then generate class diagrams from our entity relationship model. Select Tools > Hibernate > Synchronize to Class Diagram from the toolbar.
- The Synchronize form Entity Relationship Diagram to Class Diagram dialog will be shown. The entity relationship diagrams in your project show on the left hand side of the table and the target class diagram shows on the right hand side.
- Click on the entity relationship diagram cell and the preview will be shown up.
- You can name the target class diagram directly in the class diagram cell or you can synchronize to existing class diagram (if any).
- Press OK to proceed.
- Now the Synchronize to Class Diagram dialog will show up. The mapping between entity name and class name, also the column name and attribute name will be listed in the dialog. Let's change the name of the User class to Customer. And change the attribute name from firstname to firstName.
- We can specify the target for storing the output class diagram. Select Specify... in the Target Parent combo box.
- Select the root node in the tree and press the New Model button. Name the model as Class Model.
- Press OK to proceed.
- Now the class diagrams are being generated.
- Let's try to modify the description of the class PriorityType.
- You can synchronize the description from class model to the associated entity model by right click on the diagram and select Utilities > Synchronize Class Description to ERD.
- Class Description to ERD dialog will list class models which contain different descriptions with the entity model.
- Click on the entity PriorityType in the list and the differences of descriptions between class and entity model will be shown.
- Select the checkbox under Synchronize column to specify the model you would like to synchronize their descriptions.
- By selecting Synchronize members checkbox, the descriptions of the class attribute and entity column will also being synchronized.
- Uncheck the Hide equals checkbox and all the classes/entity will be listed, even their descriptions are the same.