Hello,
I have a many-to-many relationship between the A and B classes, where the table in the middle is composed of its id, the id of one side (A class) and the id of the other (B class):
Table A_B:
ID integer not null (pk);
A_ID integer not null;
B_ID integer not null;
When I try to insert a B object into A's set of Bs,
The generated SQL (show_sql=true):
insert into A_B (A_ID, B_ID) values (?, ?)
I get a database error:
Code:
ORA-01400: cannot insert NULL into ("USER"."A_B"."ID")
because it is trying to insert the record without generating an ID..
Am I supposed to have just A_ID and B_ID in the A_B table, or can I let the ID column and have hibernate generate it when inserting a new record? Please help :S, thanks in advance!
Hibernate version:2.1.6 Mapping documents: A.hbm.xml (xdoclet generated)
Code:
<set
name="Bs"
table="A_B"
lazy="false"
inverse="false"
cascade="save-update"
sort="unsorted"
>
<key
column="A_ID"
>
</key>
<many-to-many
class="B"
column="B_ID"
outer-join="auto"
/>
</set>
Name and version of the database you are using:
Oracle 9i
(no "ID" anywhere)