Persistent codes are defined for OOM classes and attributes. They are used during OOM to PDM generation in order to fine tune data storage in a relational database. They also facilitate round-trip engineering by allowing to recover object codes from the database.
You can define the type of persistence you want to implement in the Persistent group box in the Detail tab of a class property sheet:
Generate table means the class is generated in a table.
Migrate columns means the class is not generated, its attributes and associations are migrated to the generated parent or child table.
Generate ADT means the class is generated as an abstract data type, a user-defined data type that can encapsulate a range of data values and functions.
Attribute and associations of persistent classes with a persistence generation mode set to "Migrate columns" are migrated to parent or child tables.
You can also define persistent data types for class attributes and domains. For data type persistence management, you have to take into account the following parameters:
The data type is simple, based on standard OOM data types. If the data type is persistent, generation keeps persistent data type in the target model. Otherwise data type is converted to standard data type in the target model
The data type is complex, based on a classifier. If the data type is persistent, you can define different generation options according to what you want to have in the target model and to the attribute multiplicity
If you generate the following OOM into a PDM:
The migration of attributes in the generated PDM depends on the persistence option of the classes in the source OOM:
Persistence |
Result |
---|---|
Parent and child / Generate table |
Two tables are created for each class |
Parent / Migrate columns Child / Generate table |
Table Child is generated with parent attributes |
Parent / Generate table Child / Migrate columns |
Table Parent is generated, with child attributes |
Parent and child / Migrate columns |
Nothing is generated |
In the following OOM, class Customer inherits from Person via a generalization link. Person is not persistent but Customer is persistent.
Customer inherits the attributes of the parent class in the generated PDM:
A derived class is created for conceptual reasons to improve the readability of a model but it adds no semantic information. There is no point of generating a derived class in a PDM, and attributes of this class should be migrated to parent.
In the following example, class Women is created to further analyze class Employee and highlight a specific attribute "Maternity leave". This class is derived, thus not generated but persistent:
In the generated PDM, Employee inherits from parent class and also from derived class: