Hi All,
I have a strange problem(?) with inheritance mapping using <joined-subclass>. This is how my hbm looks like:
Code:
<hibernate-mapping package="pl.poznan.put.diploman.entities">
<class name='Message' table='messages' abstract="true">
<id name='id' type='long' column='message_id'>
<generator class='native' />
</id>
<property name='status' type='string' column='status'>
<meta attribute="property-type">ApplicationStatus</meta>
</property>
<property name='message' type='string' column='message' />
<many-to-one name="student" class="Student" not-null="true"
column="student_id" foreign-key="fk_students" />
<many-to-one name="team" class="Team" not-null="true"
column="team_id" foreign-key="fk_teams" />
<joined-subclass name="Invitation" table="invitations">
<key column="invitation_id" foreign-key="fk_messages" />
</joined-subclass>
<joined-subclass name="Application" table="applications">
<key column="application_id" foreign-key="fk_messages" />
</joined-subclass>
</class>
</hibernate-mapping>
And I have also hbms for Student and Team classes.
The problem is that when I generate database schema I get tables:
- messages
- invitations
- applications
Every of them has columns student_id and team_id and related foreign keys. It is quite weird for me, because I think it would be enough to have these columns only in superclass table(messages). I did specify many-to-one relation only in superclass, not in subclasses. Now I don't know which of the columns will be taken to resolve Student and Team references? It may also cause some problem with automatic data generation tools. Could somebody clarify me why it is done that way? I would like to have student_id and team_id columns only in messages table, as I specified in hbm.
Thanks,
Tomek