I'm looking at example of DiscriminatorColumn at EclipseLink page.
There are two entities
@Entity
@Table(name="PROJECT")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING,length=20)
@DiscriminatorValue("P")
public class Project {
@Id
protected BigInteger id;
protected String description;
}
@Entity
@DiscriminatorValue("L")
public class LargeProject extends Project {
protected BigInteger budget;
}
now lets say i have two records in my db
| ID | TYPE | DESCRIPTION | BUDGET |
|-----------|---------------|---------|
| 1 | P | Small Project | |
| 2 | L | Large Project | 10000 |
Is it possible to drop TYPE
table somehow, and use BUDGET
table instead?
For this case would be Project
if BUDGET
is null
otherwise it will be LargeProject
Can JPA or EclipseLink allow to do something like that, and if not, is it any reason for that?