Support of inheritance relationships
The SQL Designer module supports inheritance relationships between persistent classes. The sections which follow deal with four inheritance mapping strategies supported by Hibernate:
-
one table per class hierarchy
-
one table per child class and its variant using a discriminator
-
one table per concrete class
-
one table per concrete class using implicit polymorphism
The type of mapping applied to a given inheritance link can be configured in the SQL tab on the inheritance link in question.
One table per class hierarchy
Using this strategy, the set of persistent classes in the inheritance hierarchy is mapped to a single table of the SQL model.
Constraints at persistence model level:
-
Only the parent persistent class declares an identifier. Child classes must not have one.
-
All the properties of these classes cannot have Not Null constraints.
-
The Discriminator Column, Discriminator Column Type and Discriminator Value properties must be defined at parent class level.
One table per child class
Using this strategy, each of the persistent classes in the inheritance hierarchy is mapped to a table of the SQL model.
Constraints at persistence model level:
-
Only the parent persistent class declares an identifier. Child classes must not have one.
The SQL Designer module supports a variant of this strategy (one table per child class using a discriminator), which leads to the following constraints:
-
The Discriminator Column, Discriminator Column Type and Discriminator Value properties must be defined at parent class level.
-
The SQL table corresponding to the parent persistent class must have a column for the discriminator.
One table per concrete class
Using this strategy, each of the non-abstract persistent classes of the inheritance hierarchy is mapped to a table of the SQL model.
Constraints at persistence model level:
-
Only the parent persistent class declares an identifier. Child classes must not have one.
One table per concrete class using implicit polymorphism
This is a variation on the previous strategy. Each of the non-abstract persistent classes of the inheritance hierarchy is mapped to a table of the SQL model.
Constraints at persistence model level:
-
All the persistent classes of the inheritance hierarchy must declare the same identifier.