hi, all:
Right now I have problem with hibernate mappings:
I have 3 classes as following:
Class A {
private OtherClass1 other1;
}
Class B extends A {
private OtherClass2 other2;
}
Class C extends B {
}
I use one table to map the whole inheritance(table per class hierarchy). The mapping file is like this:
<<class
name="A"
table="tableABC"
>
<discriminator
column="type"
not-null="true"
type="string"
/>
<many-to-one
name="other1"
class="OtherClass1"
cascade="all"
outer-join="auto"
update="true"
insert="true"
column="Other1Id"
not-null="false"
/>
<subclass
name="B"
discriminator-value="typeb"
>
<many-to-one
name="other2"
class="OtherClass2"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="Other2Id"
not-null="false"
/>
<subclass
name="C"
discriminator-value="typec"
>
</subclass>
</subclass>
</class>
Here is the problem, when I create db schemas using hbm2ddl, I noticed that it create 2 identical foreign key constraint point to OtherClass2 table. But for OtherClass1 defined in Class A, only one foreign key constraint was created.
Does anybody knows why? Anything I can do to solve this problem?
This is urgent for me. So any idea will be really appreciated.
Thanks alot!
|