Using ORM Diagram
An ORM diagram is used to show the mapping between the ORM-Persistable class and its corresponding entity. VP’s products allow you to name the ORM-Persistable class and its corresponding entity differently, and also the attributes and columns as well. In some cases, you may find it difficult to identify the mappings not only between the ORM-Persistable classes and the corresponding entities, but also between the attributes and columns.
Taking the advantage of ORM diagram, the mappings between ORM-Persistable classes and entities, and between attributes and columns can be clearly identified. Let us learn the usage of the ORM diagram.
Creating ORM Diagram
You can create an ORM diagram by one of the three methods:
On the menu, select File > New Diagram > Others > ORM Diagram.
On the
Diagram Navigator, right-click
ORM Diagram > Create ORM Diagram.
On the toolbar, click the
New ORM Diagram.
Creating ORM-Persistable Class and Mapping Entity
After created a new ORM diagram, you are allowed to create an ORM-Persistable class and its mapping entity on the ORM diagram.
Creating ORM-Persistable Class
To create an ORM-Persistable class on ORM diagram:
On the diagram toolbar, click
Class icon.
Click anywhere on the diagram to create an
ORM-Persistable class.
Enter
Student as the name of the ORM-Persistable class.
Mouse over the
Student class, drag the
One-to-One Association → Class resource to the diagram to create another ORM-Persistable with a one-to-one directional association.
Enter
Profile to the name of the newly created class.
Creating Mapping Entity
To create the mapping entity of the ORM-Persistable class:
Mouse over the
Student class, click and drag the
Class-Entity Mapping → Entity resource to the diagram.
The mapping entity,
Student is created automatically.
Create the mapping entity of
Profile class by using the
Class-Entity Mapping → Entity resource.
Note: You can create the Entity and the mapping class using the same approach of Creating ORM-Persistable Class and Creating Mapping Entity by using the Entity icon on the diagram toolbar and the Class-Entity Mapping → Class resource.
Switching the View of Mapping
ORM diagram provides two views of mapping, including the mapping between ORM-Persistable class and entity (called Class Mapping), and the mapping between attributes and columns (called Attribute Mapping).
To change the view of mapping, right-click on the ORM-Diagram, select the desired view from the sub-menu of View.

Modifying ORM-Persistable Class
You can modify the ORM-Persistable class such as renaming the class name and adding attributes to the class.
Let us add three attributes, including StudentID, Name and CourseCode to the Student class.
Right-click the
Student class, select
Add > Attribute from the pop-up menu.
Note: You can add the attribute by using the shortcut,
Alt + Shift + A.
Enter
StudentID : String to the attribute.
Repeat steps 1 and 2 to add the other two attributes to the Student class as shown below.
Modifying Entity
You can modify the entity such as renaming the entity name and adding columns to the entity.
Let us rename the Profile entity to StudentProfile, and add the DateOfBirth, YearOfEnrollment as the columns of the entity.
Double-click the
Profile entity, enter
StudentProfile to rename the entity.
Note: You can edit the entity name by selecint the entity and pressing the
F2 button.
Right-click the StudentProfileentity, select New Column from the pop-up menu.
Note: You can add the column by using the shortcut,
Alt + Shift + C.
Enter
DateOfBirth : date to define the column.
Repeat steps 2 and 3 to add the
YearOfEnrollment column as shown below.
Synchronizing Attributes and Columns
To synchronize the attributes added to ORM-Persistable class to the mapping entity:
On the ORM diagram, hold down the right-mouse button, move the mouse from left to right to form the gesture which is indicated by the blue path.
The attributes are synchronized to the mapping entity automatically.
To synchronize the columns added to entity to the mapping ORM-Persistable class:
On the ORM diagram, hold down the right-mouse button, move the mouse from right to left to form the gesture.
The columns are synchronized to the mapping class.
Right-click the ORM diagram, select
View > Attribute Mapping from the pop-up menu to view the mapping in detail.
After changing the view of the ORM diagram from Class Mapping to Attribute Mapping, the ORM diagram shows as below.
Related Articles
Resources
-
-
-
-
Chapter 4 Object Model - This chapter shows how to depict the object models by using a Class Diagram or an EJB diagram, and describes the mapping from the object model to data model.
Chapter 5 Data Model - This chapter shows you how to depict the object models by using Entity Relationship Diagram and how to reverse database, and describes the mapping from the data model to the object model.