Hi,
I have trouble in one of my bidirectional one-to-one associations, using foreign key associations. I'm gonna try to keep it as simple as possible.
I have three classes, lets say Aaa, Bbb and Ccc, where Ccc extends Bbb and Bbb extends some other class. I implemented a one-to-one association between Aaa and Ccc; mapping files are as follows:
Code:
<class name="Aaa" ...>
...
<many-to-one name="ccc" class="Ccc"
column="CCC_ID" cascade="all" unique="true"/>
...
</class>
<class name="..." ...>
...
<subclass name="Bbb">
...
<subclass name="Ccc" discriminator-value="..">
...
<one-to-one name="aaa" class="Aaa"
property-ref="ccc" />
...
</subclass>
...
</subclass>
...
</class>
The problem:
when no entity is attached to the session, I want to retrieve a Ccc object by its id.
session.get(Ccc.class, id) works fine, no problem. but
session.get(Bbb.class, id), the returned Ccc object's aaa property is null.
I totally understand why this happens, but I want to know if there is a solution to this other than declaring <many-to-one> in both sides.
Thanks in advance..