Chapter 4 Generating Hibernate Persistent Objects and JSF Pages


Table per class hierarchy

Using a table per class hierarchy means that all attributes of subclasses are migrated to the parent class.

The following diagram shows inheritance mapping:


The following diagram shows the parent table:


Steps To define a table per class hierarchy:

  1. Open the property sheet of the root class, click the Details tab, and select "Generate table".
  2. Add an attribute that will be used as a discriminator column.
  3. Click the Hibernate tab and specify the discriminator column name, value, and type.
  4. Open the property sheet of a subclass, click the Details tab, and select "Migrate column".
  5. Click the Hibernate tab and specify a discriminator value (which should be unique for each subclass).
  6. Generate a PDM with O/R mapping.
  7. Verify the mapping file in the Preview tab of the root class property sheet.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.