Hibernate version: 2.1.2
...
Name and version of the database you are using: db2 v8.1.0.72
I have a complicated table structure that I'm not at liberty to change and I'm wondering the appropriate way to map it.
I have a set of three tables "doc_edition_wrk", "doc_edition_que", and "doc_edition_his". These three tables have exactly the same structure apart from two columns in his and que that aren't in wrk. As you might expect, the data progresses through the three tables as it becomes
active so I could be looking for a row and not know in which of the three tables it will be found at any given time.
I have the three tables mapped to the following classes: DocumentEditionWork, DocumentEditionQueue, and DocumentEditionHistory. The three classes all implement an interface called DocumentEdition.
DocumentEdition is not mapped to any table, so there is no mapping file to put <subclass> declarations in.
This works partially. I can do an HQL
Code:
from DocumentEdition where ...
queries with no problems. But now I need to map a one-to many relationship to these three tables. Like so:
Code:
<list name="documentEditions">
<key>
<column name="edtn_id"/>
</key>
<index column="occurrence"/>
<one-to-many class="DocumentEdition"/>
</list>
Is there a way to do this? I've been going through
Hibernate In Action section 3.6, which seems to imply that the interface DocumentEdition should be mapped to a table and its implementing classes should have <subclass> declarations back to it, but there is no appropriate table to map the interface to.
Is it possible to map an interface to NO table, so there's a mapping to the interfaces implementors as subclasses? Or, more likely, am I going about this the wrong way entirely?