Package org.hibernate.annotations
Annotation Interface DiscriminatorFormula
Specifies an expression written in native SQL as the discriminator for an
entity inheritance hierarchy. Must be used to annotate the root entity of
the hierarchy.
Used in place of the JPA DiscriminatorColumn
.
For example, we might declare a supertype as follows:
@Entity @DiscriminatorFormula(discriminatorType = INTEGER, value = "case when value1 is not null then 1 when value2 is not null then 2 end") public abstract class AbstractChild { @Id @GeneratedValue Integer id; ... }
and then each concrete subclass must specify a matching discriminator value:
@Entity @DiscriminatorValue("1") public class ConcreteChild1 extends AbstractChild { @Basic(optional = false) @Column(name = "VALUE1") String value; ... }
@Entity @DiscriminatorValue("2") public class ConcreteChild2 extends AbstractChild { @Basic(optional = false) @Column(name = "VALUE2") String value; ... }
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe type of value returned by the formula.
-
Element Details
-
value
String valueThe formula string.
-
-
-
discriminatorType
DiscriminatorType discriminatorTypeThe type of value returned by the formula.This is required, unless the expression is of type
varchar
or similar.- Default:
- STRING
-