I'm using JPA JOINED inheritance strategy with 3 abstract classes and 2 concrete. Like this (code reduced for example purpose):
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
abstract class Employee {
@Id
private Long id;
private String firstName;
private String secondName;
}
@Entity
abstract class ProjectManager extends Employee {
@OneToMany(mappedBy="manager")
private List<Developer> developers;
}
@Entity
abstract class Developer extends Employee {
@ManyToOne
@JoinColumn(name="project_manager_id")
private ProjectManager manager;
}
@Entity
class JavaProjectManager extends ProjectManager {
private String someCustomProperty;
}
@Entity
class JavaDeveloper extends Developer {
private String skill;
}
This way, JPA creates 5 tables. But one of this tables, abstract ProjectManager it is empty. I mean, ProjectManager table only have ID column due to inheritance strategy.
My question is: how I can avoid this extra table for ProjectManager abstract class but keeping the same hierarchy of classes ?
I could not remove @Entity on ProjectManager class because I still need bidirectional relationship with Developer class.
Edit:
Also, I don't want move developers OneToMany from ProjectManager to JavaProjectManager, because I have more classes that extends from ProjectManager and need to have developers.