Skip Headers
Dali Java Persistence Tools User Guide
Release 3.2
Release 3.2
  PDF
PDF
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Specifying additional tables
 
Next
Creating queries
 

Specifying entity inheritance

An entity may inherit properties from other entities. You can specify a specific strategy to use for inheritance.

Use this procedure to specify inheritance (@Inheritance) for an existing entity (@Entity):

  1. Select the entity in the Project Explorer.

  2. In the JPA Details view, select the Inheritance information.

    Figure 3-42 Specifying Inheritance

    Selecting the Inheritance area on the JPA Details view.
  3. In the Strategy list, select one of the following the inheritance strategies:

    • A single table (default)

    • Joined table

    • One table per class

  4. Complete the fields in the Inheritance area.

    Use the following table to complete the remaining fields on the tab. See "Inheritance" for additional details.

Eclipse adds the following annotations the entity field:

@Inheritance(strategy=InheritanceType.<INHERITANCE_STRATEGY>)
@DiscriminatorColumn(name="<DISCRIMINATOR_COLUMN>",
    discriminatorType=<DISCRIMINATOR_TYPE>)
@DiscriminatorValue(value-"<DISCRIMINATOR_VALUE>")
@PrimaryKeyJoinColumn(name="<JOIN_COLUMN_NAME>", 
    referencedColumnName = "<REFERENCED_COLUMN_NAME>")

The following figures illustrates the different inheritance strategies.

Figure 3-43 Single Table Inheritance

This figure illustrates entity inheritance in a single table.

Figure 3-44 Joined Table Inheritance

This figure illustrates a joined subclass inheritance strategy.

Related reference

Related concepts