Hello,
Here's my scenario: I'm working with a legacy database, where inheritance was implemented using
both table-per-class and table-per-subclass schemas. In other words, there's always a discriminator column in "super" tables, even where the hierarchy can be completely recovered using joins.
So, I've decided that the best strategy is to use the table-per-class schema and adopt
<join table...> tags to "emulate" table-per-subclass when applicable. Generically:
Code:
<class ...>
<id ..../>
<discriminator .../>
<join table=...>
<key .../>
<property .../>
...
</join>
</class>
So far, so good. But...
I've noticed that Hibernate (ver. 3.1 and below) doesn't support
<many-to-one> relationships inside joined tables.
- Why?
(Performance? Postponed feature? Gotchas?)
- How to circumvent this limitation?
My first tought was to implement a class to represent the "extra" data (i.e., the data of the joined table, including collections) and link it to the main entity with one-to-one relationship. To make this transparent, I'd implement getters/setters in the main entity that just redirect calls to extraData.get... and extraData.set... .
However, it seems that I'm adapting my entity model to the persistence layer, which sounds strange at first.
I'd like to hear developers that have faced this situation before...
Also, I see that this is an open issue since nov/04 (
Issue #HHH-36), but there hasn't been any comments since then.
Thanks in advance,