How to delete entities from many-to-many and and many-to-one relationships
I've got stuck in a problem and I feel it's real important to understand it thoroughly!
I have a many-to-many relationship, which is mapped unidirectional (with a set). If I delete an entity from the table, which contains the set definition, then the corresponding rows from the link table are also deleted...but when I try to delete an entity from the many side, which contains no set definition, I get an error. Is the only solution for this problem, to make the relationship bidirectional?
The same problem appears for the many-to-one relationship, which I have only mapped on the many side. If I try now to delete an entity from the one side, and that entity has a corresponding entity child on the many side, then I'm not allowed to delete it. Again, do I need to make the relationship bidirectional or is there any other solution?
I've read that it's not recommended to make relationships bidirectional.