Hello
I'm using Hibernate 3.2 (in JBoss 4.0.5) and Oracle 10i.
I have the following situation:
A hierarchy of classes:
class A
class B extends A
class C extends B
class D extends C
Classes A,B and C are all stored in the same DB table, AT1.
Class D has its own table DT2.
The subclassing is done using a discriminator that resides in table AT1.
The hierarchy itself is working as expected.
Now I have another class E with its own table ET3.
It happens that E has a list of D:
Code:
<class name="E" table="ET3">
<id name="id" column="id" type="java.lang.Long">
<generator class="sequence">
<param name="sequence">SQ_ET3</param>
</generator>
</id>
<!-- some properties... -->
<!-- E has a list of D -->
<bag name="list_of_d" inverse="true"
cascade="all-delete-orphan">
<key column="e_id" not-null="false" />
<one-to-many class="E" />
</bag>
</class>
When I added a DT2.e_id field into DT2 referencing ET1.id I noticed that Hibernate complained that "AT1.e_id does not exist" (SQLGrammarException).
I moved that field to AT1 but same error with "ET1.e_id does not exist".
So in the end I had to add the field e_id into both AT1 and DT1 tables.
But I find it rather strange and was wondering if it's the right way to do it?