Mapped superclass


An entities that extend a Mapped Superclass class inherit the persistent state and mapping information from a superclass. You should use a mapped superclass to define mapping information that is common to multiple entity classes.

A mapped superclass can be:

A mapped superclass cannot be:

A mapped superclass does not have a defined database table. Instead, its mapping information is derived from its superclass. To override the mapping information for a specific subclass, use the @AttributeOverride annotation for that specific class.

A mapped superclass is identified by the @MappedSuperclass annotation.

Use this procedure to add Mapped Superclass persistence to an existing entity:

  1. Right-click the class in the Package Explorer and select Persistence > Make Java Persistence Entity.

    Adding Persistence to a Class

    Using the Persistence > Make Java Persistent Entity menu option.
  2. In the Persistence Properties view, use the Map As drop-list to select Mapped Superclass.

    Selecting Mapped Superclass Persistence

    Selecting embedded persistence on the Persistence Properties view.
  3. Complete the remaining Persistence Properties view (for entities).

 

Related tasks

Adding persistence to a class