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 BCode:
<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..