Hibernate many-to-many self-reference, how to delete without cascade?

You'll just have to remove the relationships yourself. To do this, before removing the person A, you'll have to find all the persons who have A in their set of related persons, and remove A from these sets. If you don't, then of course you can't delete A because other persons still reference A.

You'll just have to remove the relationships yourself. To do this, before removing the person A, you'll have to find all the persons who have A in their set of related persons, and remove A from these sets. If you don't, then of course you can't delete A because other persons still reference A.

Either do this with a HQL query and remove A from the sets of the found persons in Java, or use a dedicated SQL delete query to remove all the rows from the join table. But be aware that this SQL query will bypass the caches (first-level and second-level, if any), and your session might thus hold an incorrect view of the database.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions