Actually I have a mother class with a JOINED inheritance. This class has a child class which is also a mother class and abstract with a SINGLE TABLE inheritance.
The problem is :
If I set a Discriminator Column on the SINGLE TABLE mother class, it wont’ apply the Discriminator Column on this class.
How can I set a Discriminator column on my abstract class table
@Entity
@Inheritance(strategy = JOINED)
public class DiagnosticGenerique extends Diagnostic {
(...)
}
@MappedSuperclass
@DiscriminatorColumn(name = "ROLE", columnDefinition = "varchar2(120)")
@Inheritance(strategy = SINGLE_TABLE)
@Table(name = "TDIAGNOSTICCHAUDFROIDURBAIN")
public abstract class AbstractDiagnosticChaudFroidUrbain extends DiagnosticGenerique {
(...)
}
@Entity
@DiscriminatorValue(value = "DiagnosticChauffageUrbain")
@Table(name = "TDIAGNOSTICCHAUDFROIDURBAIN")
public class DiagnosticChauffageUrbain extends AbstractDiagnosticChaudFroidUrbain {
(...)
}
But then, why in the JavaDoc of the DiscriminatorColumn class we have that :
Specifies the discriminator column for the SINGLE_TABLE and JOINED Inheritance mapping strategies.
The strategy and the discriminator column are only specified in the root of an entity class hierarchy or subhierarchy in which a different inheritance strategy is applied
If the DiscriminatorColumn annotation is missing, and a discriminator column is required, the name of the discriminator column defaults to “DTYPE” and the discriminator type to DiscriminatorType.STRING.
The part that catches my eye
or subhierarchy in which a different inheritance strategy is applied
Which mean that it’s possible right ?
Or maybe possible in differents ORM but not in Hibernate ?
JPA and Jakarta specs does not require support for the combination of inheritance strategies, and Hibernate does not support it but yes it may be possible implementations support it.
Support for the combination of inheritance strategies is not required by this specification. Portable applications should only use a single inheritance strategy within an entity hierarchy.