NHibernate remove many of many, causing a foreign key violation

I have a problem with a fairly simple setup in NHibernate. (I am using Fluent Nhibernate)

I have two objects as follows: a bidirectional display setup many-many.

Project

- Categories (IList)

Category

- Projects (IList) - Inverse = True

This models as expected in db.

If I try to delete a project, NHibernate will delete the many-to-many table, and then delete the project as expected.

However, if I try to remove the NHibernate category, you will get an exception that violates the foreign key constraint.

I have an experiment with inverse = "true" on both sides, but an exception occurs either when I try to delete Project, or in a category (depending on where inverse = "true"). If I remove inverse = "true" on both sides, the removal works as expected at both ends. But when saving and updating this leads to double entries.

Can someone tell me where I am going wrong?

+3
source share
1 answer

, ? , , . Hibernate , . (), , .

+3

Source: https://habr.com/ru/post/1721746/


All Articles