Used in place of the JPA jakarta..
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;
...
}
Formula, DialectOverride.DiscriminatorFormula
| Modifier and Type | Method and Description |
|---|---|
| public DiscriminatorType | |
| public String |
| discriminatorType | back to summary |
|---|---|
| public DiscriminatorType discriminatorType() The type of value returned by the formula.
This is required, unless the expression is of type | |
| value | back to summary |
|---|---|
| public String value() The formula string. | |