I have 3 entities:
@Entity
public abstract class A {
@Id
public Long id;
public String a1;
public String a2;
public String a3;
//much more fields
//getters and setters
}
@Entity
public class B extends A {
public String b1;
public String b2;
public String b3;
//much more fields
//getters and setters
}
@Entity
public class C extends A {
public String c;
//that's it. no more data
//getters and setters
}
I want to map these classes to 2 tables. First one will contain all of A and C data (i.e. SINGLE_TABLE inheritance). And the second one will contain B's data and a foreign key to A (i.e. JOINED inheritance).
I tried the solution proposed here, but it doesn't work for me. The attributes of BB1 and BB2 are also included into A.
How to implement such a strategy? Classes A and C are as different as Dog and Cat are, so I can't merge them into one class.
Also I don't want to use table-per-hierarchy which would result in duplicating lots of A's data.