-->
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: database schema, inheritance and self-referencing
PostPosted: Mon Oct 10, 2005 9:07 pm 
Newbie

Joined: Tue Jul 27, 2004 12:33 pm
Posts: 2
Hibernate version:
Hibernate 3.0.2

Mapping documents:
Code:
    <class name="A">
      <id name="id">
         <generator class="sequence">
            <param name="sequence">id_seq</param>
         </generator>
      </id>
        <many-to-one name="backLink"/>
    </class>
    <joined-subclass name="B" extends="A">
        <key column="id"/>
        <set name="as" inverse="true">
            <key column="backLink"/>
            <one-to-many class="A"/>
        </set>
    </joined-subclass>


Generated database schema:
Code:
create table A (id int8 not null, backLink int8, primary key (id))
create table B (id int8 not null, primary key (id))
alter table A add constraint FK41D36BE61D foreign key (backLink) references B
alter table A add constraint FK41D36BE61C foreign key (backLink) references A
alter table B add constraint FK4254F609D6 foreign key (id) references A
create sequence id_seq


Hello, I think that either I'm doing something wrong, either the generated database schema is wrong. I shouldn't get two foreign key constraint on backLink, only the one that references the base class ...

The problem is not happening, if I'm not referencing the base class from the subclass, but from an other 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.