JPA : Inheritance with join and ManyToOne
Well, I'm working In a project where it's defined the following relation in the database . I have dates that can be of different types . We can find TypeA date and TypeB date . This case, with JPA // Hibernate I have represented via InheritanceType.JOINED to create three tables . The father table ( DATE ) , and the DATE_TYPE_A table, and the DATE_TYPE_B table.
on the other side, either DATE_TYPE_A instances or DATE_TYPE_B instances can take place in diferent places, so DATE_TYPE_A has a relation of manyToOne with PLACE A and DATE_TYPE_B has a relation with PLACE B of manyToOne.
ok, once the problem has been presented, I can't mix everything . The place A looks for the identifier of DATE_TYPE_A :
private List listaCitas;
and in DATE_TYPE A :
private CentroSaludEntity centroSalud;
The problem appears when PLACE_A looks for citaId, As I have defined this kind of inheritance, citaId is present in the father table, not in sons, so it cant be found . I can use a SINGLE_TABLE_INHERITANCE, of course, but I want to know if there's a way to reference the father identifier.