Case:
Classes:
Class C(pk);
Class RA(), RB(), RC() extends R()
Class PA(), PB extends P(pk);
C (1)----(n) R (n)----(1) P
DB model:
C_TABLE (ID, ... , primary key(ID));
R_TABLE (C_FK, P_FK, R_CODE, primary key(C_FK, P_FK, R_CODE));
C_FK foreing key to C_TABLE.ID
P_FK foreing key to P_TABLE.ID
P_TABLE (ID, primary key(ID));
PA_TABLE (ID, ..., primary key(ID));
ID foreing key to P_TABLE.ID
PB_TABLE (ID, ..., primary key(ID));
ID foreing key to P_TABLE.ID
Navigation:
from C get all Rs and for one R get the P
from Rs get C or P
from Ps get all Rs and for one R get the C
Mapping:
- imagined:
class C mapped on C_TABLE
classes RA, RB, RC, R mapped using Table Per Class Hierarchy strategy on R_TABLE
classes PA, PB, P mapped using Table Per SubClass strategy on PA/PB/P_TABLE
Problem:
The problem comes when trying to define the mapping for RA, RB, RC, R!
In the given context I'm not able to define a correct mapping for hibernate, specially
when trying to define the <id> or <composite-id> for R (with RA, RB, RC subclasses) mapping.
Is it possible for the given DB model to have an Inheritance mapping for R, RA, RB, RC on the R_TABLE ?
The main Constraint is the DB model.
Would be any solution with minimum modification on the DB?
Should I use a different mapping that the imagined one?
thx a lot,
tudors.
|