I have a complex object inheritance structure as follows:
- A super class called Base.
- 4 sub classes called A, B, C, and D.
- C and D has more sub classes called C1, C2, C3, and D1
I want to have A in one table, B in one table, C & C1 & C2 & C3 in one table, and D & D1 in one table.
The first obvious solution is to not mark the Base super class with any annotations, just let it be an standard abstract class. All others are annotated with @Entity. Then we annotate the C* and D* classes with the @Inheritance annotation with the inheritance type SINGLE_TABLE.
This works fine.
But here is the problem. The super class has a number of attributes that should be persisted. To make them actually be persisted, I have to override all the getters in the A, B, C, and D classes and annotate them (with @Id, @Column, @OneToOne, @JoinColumn, and so on...). So instead of just having the attributes in the super class I have to duplicate them in the sub classes.
Is there a way for me to solve this? Just to annotate the super class with @Entity does not work.
Thanks
/Patrik
|