I have this strange hierarchy:
- Class
A
is abstract (but it is an entity) - Class
B
(abstract) and C both extend classA
(TABLE_PER_CLASS). - Class
B
is also extended by classesD
andE
but this time it is JOINED.
I want the ID
of the A
class to be the ID
of all others.
Can this be done?
I get strange errors of IDs. can any one show me how to map?
This is how I did it:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class A {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
protected Integer id;
}
Class C:
@Entity
@Table(name = "managers")
public class C extends A {
Class B:
@Entity
@Table(name = "bb")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "discriminator", discriminatorType = DiscriminatorType.STRING)
public abstract class B extends A {
Class C,D:
@Entity
@Table(name = "cc"/"dd")
@DiscriminatorValue("CC"/"DD")
public class C (or D) extends B {