Hi!
I hava a problem with a one-to-many association to a subclass. The object structure is the following:
Code:
class Superclass{}
class SubClass extends Superclass{
int foreignKey;
}
class ReferencingClass {
Set<SubClass> objects;
}
For the inheritance I use the table-per-sublcass approach. The mapping of the ReferencingClass contains the following code:
Code:
<set name="objects" table="subclass_table" >
<key column="foreign_key"/>
<one-to-many class="SubClass"/>
</set>
Now when I try to load a ReferencingClass object from my database, Hibernate fails, because it tries to submit the following query:
Code:
SELECT superclass.foreign_key FROM superclass_table superclass JOIN subclass_table subclass
Obviously, the problem is that foreign_key is not in the superclass_table, but in the subclass_table.
Is this a bug in Hibernate, or am I doing something wrong? Any help or a workaround would be appriciated.
I'm using Hibernate 3.2.5 and MySQL 5.0.27
best regards,
Nil