-->
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.  [ 1 post ] 
Author Message
 Post subject: hbm2ddl problem with inheritance and one-to-many
PostPosted: Wed Sep 27, 2006 11:39 am 
Newbie

Joined: Wed Jan 04, 2006 9:13 am
Posts: 10
Location: Ukraine, Odessa
A have next classes
Code:
SuperClass
      |
      |  *    1
SubClasss-----HolderClass

When I try to generate schema with SchemaExport, i get next tables
Code:
       FK
SuperClass-----
      |PK     |
      |FK   PK|
SubClasss-----HolderClass
       FK

But schema must be
Code:
SuperClass
      |PK           
      |FK   PK   
SubClasss-----HolderClass
       FK

Why schema generator create aditional FK from SuperClass to HolderClass?

Mappings
Code:
<class name="SuperClass" table="locations" discriminator-value="0">
   <id name="idSuperClass" type="short">
      <column name="id_super_class" />
      <generator class="assigned" />
   </id>
   <discriminator type="byte">
      <column name="class_type" />
   </discriminator>
   ......................................
</class>

<subclass name="SubClass" extends="SuperClass" discriminator-value="1">
   <join table="SubClass">
      <key>
         <column name="id_super_class" />
      </key>
      <many-to-one name="holderClass" class="HolderClass" >
         <column name="id_holder_class" />
      </many-to-one>
      ......................................
   </join>
</subclass>

<class name="HolderClass" table="HolderClass">
   <id name="idHolderClass" type="short">
      <column name="id_holder_class" />
      <generator class="assigned" />
   </id>
   <bag name="subClassList" table="SubClass" inverse="true">
      <key column="id_holder_class" />
      <one-to-many class="SubClass" />
   </bag>
   ......................................
</class>


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.