Hitachi

uCosminexus Application Server Compatibility Guide


9.13.1 Inheritance class types

The inheritance class types of an entity class include the abstract entity class, mapped super-class, and non-entity class. The following is a description of each type:

Organization of this subsection

(1) Abstract entity class

You can define an abstract class as an entity class. An abstract entity class differs from the concrete entity class in that an abstract entity class cannot create an instance directly. An abstract entity class can be mapped as an entity and can also be specified as a query target for operating/obtaining the subclass entity.

With a subclass, the accessor method of the property can be overridden. However, if the O/R mapping information on the persistence fields and persistence properties is overridden in a subclass, the operations might not function properly. To override the O/R mapping information in a subclass, use @AssociationOverride or @AttributeOverride.

You specify the abstract entity class in @Entity or the O/R mapping file.

(2) Mapped superclass

A mapped superclass is a class that can become the superclass of an entity class. You can define the persistence fields and mapping information and also set a configuration to inherit the persistence fields and mapping information.

A mapped superclass cannot specify a specific table, so @Table cannot be specified. Therefore, the mapped superclass cannot be set as an entity. Unlike the entity class, a mapped superclass cannot issue a query, so the mapped superclass cannot be passed to the arguments of EntityManger and query operations. Also, a mapped superclass cannot be set as a relationship target.

A mapped superclass can be defined as an abstract class as well as a concrete class. To define a class as a mapped superclass, define @MappedSupperclass or <mapped-superclass> tag in the O/R mapping file. The mapping information is provided for the inherited entity class.

A class designed as a mapped superclass can be mapped using the same method as the entity class, except when the mapping can only be provided for the subclasses.

If an entity is applied as a subclass, the information specified in the mapped superclass is inherited in the subclass. By using @AssociationOverride or the corresponding XML element in the O/R mapping file, the mapping information can be overridden in the subclass.

(3) Non-entity class of the entity inheritance hierarchy

An entity class can have a superclass of a non-entity class. A superclass can be defined as a concrete class and abstract class.

A superclass of a non-entity class has the following features:

Do not set a non-entity class in the method arguments of EntityManager and the Query interface and in the mapping information. In Cosminexus JPA Provider, an exception occurs during the execution of the application.