Hibernate version:
2.1
I ran into a problem while creating mapping for legacy data, which is not designed quite clearly.
I have the following mappings:
[code]
<class name="Office" table="OFFICE">
<composite-id>
<key-property name="code" column="CODE" ... />
<key-property name="validToDate" column="VALID_TO_DATE" ... />
</composite-id>
...
</class>
<class name="Characteristics" table="CHARACTERISTICS">
...
<many-to-one ... class="Office">
<column name="CODE" />
</many-to-one>
</class>
[/code]
The table OFFICE contains historical data (hence the VALID_TO_DATE column) but CHARACTERISTICS refers to OFFICE regardless of date. I can't map the CHARACTERISTICS.CODE column to the OFFICE.CODE column because the OFFICE.CODE column is only part of the key.
The only working solution I know would be to add new trivial table, say, HISTORYLESS_OFFICE with one id column CODE and create many-to-one mappings Characteristics -> HistorylessOffice and Office -> HistorylessOffice. I successfully applied this solution a month ago, but I cannot change the database model at present. It would help me if I could only define the HistorylessOffice class but the class would not have any equivalent table.
Please, is there any possibility of doing it? Or some quite another way to work around it?
Thanks for any help.
Tomas
|