Hello,
I ran into a problem mapping a Set on a joined-subclass where I use a mapping key from its superclass. Here follows an example scenario:
Example mapping:
Code:
<class name="User">
<id name="id" type="long" unsaved-value="null" >
<generator class="increment" />
</id>
<property name="username" type="string" />
<set name="subclassesA" inverse="true">
<key column="userid" />
<one-to-many class="SubclassA"/>
</set>
<set name="subclassesB" inverse="true">
<key column="userid" />
<one-to-many class="SubclassB" />
</set>
</class>
<class name="SuperClass">
<id name="id" type="long" unsaved-value="null" >
<generator class="increment" />
</id>
<many-to-one name="user" column="userid" class="User"/>
.. more properties ..
<joined-subclass name="SubclassA">
<key column="id"/>
.. more properties ..
</joined-subclass>
<joined-subclass name="SubclassB">
<key column="id"/>
.. more properties ..
</joined-subclass>
</class>
Interesting generated query details:
selecting properties,
inner joining SuperClass on SubClass,
and then..
WHERE SubclassA.userid = ?
So basically it seems like hibernate forces the column to be from the Sub class, SubclassA. I was wondering if there's a way to tell hibernate to use a column from the super class, SuperClass.
Anyone with an idea how to get this working?
Version:
Hibernate 3.0.5