Managing Complex Data Type Persistence

In the following example, both classes are defined as persistent.

Class Customer contains an attribute address with a complex data type ADDRESS. This data type is based on the code of class Address.



For more information on how to use a class as a data type, see Attaching a Classifier to a Data Type or a Return Type.

When you apply a persistent complex data type to a class attribute or a domain, you can define the following different generation options:


Generating as Persistent Class

In the Detail page of the property sheet of an attribute using a complex data type, you have to select:


  • The Persistent check box

  • Persistent in the Class Generation list

After OOM to PDM generation, both classes become tables and a reference is created between them. This reference contains a join linking the primary key column in the parent table Address (this column is new, it was created during generation) and the foreign key column in the child table Customer. The foreign key column stands for the attribute using a complex data type in the OOM.

For example, if you define the standard data type generation options in the Address/Customer example, the generated PDM is the following:



The reference contains a join between Address_ID (new column in table Address) and address in child table Customer. Address_ID contains the primary key migrated to column address.

Generating as Embedded Class

In the Detail page of the property sheet of an attribute using a complex data type, you have to select:


  • The Persistent check box

  • Embedded in the Class Generation list

After OOM to PDM generation, all the attributes of the class used as data type are embedded into the table containing the attribute with complex data type. These attributes are prefixed by the name of the attribute using the complex data type.

For example, if you define the embedded data type generation options in the Address/Customer example, the generated PDM is the following:



All the attributes of class Address are embedded into table Customer and prefixed by "address" which is the name of the attribute using Address as complex data type.

Generating as Abstract Data Type Class

In the Detail page of the property sheet of an attribute using a complex data type, you have to select:


  • The Persistent check box

  • Embedded in the Class Generation list

You also have to select the Abstract Data Type check box in the Detail page of the property sheet of the class used as data type.

After OOM to PDM generation, the class used as data type becomes an abstract data type.

For example, if you define the abstract data type generation options in the Address/Customer example, the generated PDM is the following:



Class Address is generated as an abstract data type attached to column address in table Customer.


Created October 7, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com