I have a many to many with a link table and every time i delete one of the objects i get a foreign key violation on the link table.
I am using hibernate 3, but an older version of it
Using the author/book example here is what my mappings look like:
For author: <set name="books" table="author_book" inverse="true" cascade="save-update" > <key> <column name="author_id" not-null="true"/> </key> <many-to-many class="Book"> <column name="book_id" unique="true"/> </many-to-many> </set>
For book: <set name="authors" table="author_book" inverse="false"> <key> <column name="book_id" not-null="true"/> </key> <many-to-many class="Author"> <column name="author_id" unique="true"/> </many-to-many> </set>
My expectation is that when I delete an author the entry in the link table will be removed as well, but the book stays active.
However, when I delete an author I get a foreign key violation on the link table. I have tried countless different settings and I always get the same result.
What am i doing wrong? thanks
|