Hibernate version:
3.0.5
Hi,
I am trying to map a subclass but none of the strategies in the documentation seem to match my need. Consider:
A class OrgUnit, with sub-classes Company and Outlet.
In our database this is represented by:
Table ORG_UNIT:
ORGU_ID bigint not null,
LCOUNT bigint not null,
ORGU_CODE varchar(255),
COMP_ID bigint,
OUTL_ID bigint,
ORGT_TYPE_ID bigint not null,
ORGU_DEF_LEGT_ID bigint not null,
primary key (ORGU_ID),
unique (ORGU_CODE),
unique (ORGU_DEF_LEGT_ID),
foreign key (COMP_ID) references COMPANY,
foreign key (OUTL_ID) references OUTLET,
foreign key (ORGT_TYPE_ID) references ORG_TYPE
Table COMPANY:
COMP_ID bigint not null,
LCOUNT bigint not null,
-- other cols
primary key (COMP_ID)
Table OUTLET:
OUTL_ID bigint not null,
LCOUNT bigint not null,
-- other cols
primary key (COMP_ID)
Table ORG_TYPE:
ORGT_TYPE_ID bigint not null,
ORGT_TYPE_NAME varchar(60) not null,
ORGT_TYPE_CONST bigint not null,
LCOUNT bigint not null,
-- other cols
primary key (ORGT_TYPE_ID)
so, if i get an ORG_UNIT with a COMP_ID not null and a ORGT_TYPE_ID with an associated ORGT_TYPE_CONST of 1 then i want a Company coming back from a query. Similarly if it has an OUTL_ID, and ORGT_TYPE_CONST of 2, then I want an Outlet. If neither I just want a raw OrgUnit.
|