Applying Table Per Class Hierarchy Strategy

The whole class hierarchy should be mapped to one table. There should be one discriminator column defined to distinguish instances of difference classes in the hierarchy. The column can have character based type or integer type.





  1. Define class mappings for each class in the hierarchy.

    All the classes have the same primary table. They can also be mapped to other secondary tables.

  2. Define identifier mapping in the root class.
  3. Define attribute mappings or association mappings for each class.
  4. Define discriminator column in the root class.

For each class hierarchy, a discriminator is needed to distinguish between different class instances. You have to select one of the attributes in the root class, in the Specifying Attribute list of the property sheet of one of the children inheritance links of the root class. The attribute will be transformed into a discriminator column. In the following example, we define one extra attribute shapeType in Shape and select it as discriminator attribute:




  • Define persistence generation type for each class. Define the persistence generation type of the root class as Generate table and all the other classes as Migrate columns.


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