-->
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: two foreign keys to one table - problem
PostPosted: Fri Nov 10, 2006 9:04 am 
Newbie

Joined: Fri Nov 10, 2006 7:51 am
Posts: 2
Hibernate version: 3.0

Mapping documents:

class A
Code:
<id name="id" column="id">
    <generator class="sequence">
        <param name="sequence"> a_sequence </param>
    </generator></id>
<set name="b1Set" inverse="true" cascade="all">
        <key column="id"> </key>
        <one-to-many class="....B"/>
</set>
<set name="b2Set" inverse="true" cascade="all">
        <key column="id"> </key>
        <one-to-many class=" ... .B"/>
</set>


class B
Code:
<many-to-one name="id_1" class="...A" column="id" not-null="true">
<many-to-one name="id_2" class="...A" column="id" not-null="true">


Name of the database:
postgresql
The generated SQL:
Code:
CREATE TABLE b
(
  id_p int8 NOT NULL,
  id_1 int8 NOT NULL,
  id_2 int8 NOT NULL,
  ...
  id int8,
  CONSTRAINT b_pkey PRIMARY KEY (id_p),
  CONSTRAINT fk3498a013dbde52 FOREIGN KEY (id)
      REFERENCES a (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk3498a06f46c8b1 FOREIGN KEY (id_1)
      REFERENCES a (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT fk3498a0f37e3f6b FOREIGN KEY (id_2)
      REFERENCES a (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)

problem
In the table b there is id (from a), why? I want only id_1, id_2
Has anybody such a situation that one table has two foreign keys to another (same)table?
Why is there aditional id? I havent that when i have in the table A no sets..


Top
 Profile  
 
 Post subject: two foreign keys to one table - problem
PostPosted: Sat Nov 11, 2006 7:00 pm 
Newbie

Joined: Fri Nov 10, 2006 7:51 am
Posts: 2
ok there was an error with sets


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.