-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: joined-subclass and duplicated database columns for M-2-O
PostPosted: Fri Nov 21, 2008 9:55 am 
Newbie

Joined: Fri Jul 25, 2008 12:21 am
Posts: 2
Location: Poland
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 24, 2008 6:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
have you looked in jira to see if there is an existing bug for schemaexport/hbm2ddl ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.