I have tables Person(PID a PK), Content (ID as PK), ContentType (CTID as PK) and a linking table Person_Content ( PID, CID, CTID). Unfortuantely, ContentType(CTID) is not part of Content ( that would be a normal design but I cannot change the legacy table at this point).
In the object domain, I have CONTENT class and different subclasses of Content based on ContentTypeID( eg. PDF, IMAGE, TEXT etc. ).
I am going with a table per class hierarchy strategy.
The problem here is CTID is a discriminator column for my subclasses but I cannot specify in Content.hbm.xml because that column does not exist in Content table.
I thought about using discriminator formula=" select CTID from CONTENTTYPE" but it is returning multiple rows and my understaning is, it should return only one row for each content.
Is there a HIbernate way of tackling this situation without changing the DB schema?
Thanks in advance
|