Let's use the example of departments within a company. A particular employee can be a member of more than one department.
So, I have a unidirectional many-to-many association where each department contains a set of employees.
When an employee is deleted, I want him deleted from any department(s) that he may be associated with. This is resulting in an "integrity constraint violation" with respect to the association table.
I assume I can configure hibernate to make this work for me. Note that I do not want the deletion of a department to result in the deletion of all employees in the department; the life cycles of the 2 objects are independent.
I have looked at the cascade attribute, but I don't see a value that does what I need.
Is the solution to make the association bi-directional? Is there some other way?
Thanks!
|