Regarding bug:
http://opensource.atlassian.com/project ... se/HHH-368
(reposting here, because I posted in the bug before, and was told to post here)
I realize this is a closed issue, but hopefully I can get a clarification that will probably help other people with the same question as mine.
It appears to me, after reading this bug report (I have the same problem as the original submittor, by the way), that the following is the case:
Suppose that we have a many-to-many mapping between Employees and Departments. An Employee can belong to many Departments, and a Department can contain many Employees. Both are managed with Sets. Assume Department->Employee is the main association, i.e. inverse="true" is defined in the Employee set in the Department mapping file.
From what I read above, it appears that this code used to work:
Code:
// Assume d is a Department, e is an Employee, initialized elsewhere.
d.getEmployees().remove( e );
e.getDepartments().remove( d );
session.save( d );
// The association in the join table between employee and department
// has been removed by this point, because of cascading
But that same code, in hibernate 3, will not work, as it will not remove the association between the two objects that is in the join table. Instead, we need to craft a query to delete it by hand. Something more along the lines of:
Code:
// Assume d is a Department, e is an Employee, initialized elsewhere.
d.getEmployees().remove( e );
e.getDepartments().remove( d );
session.save( d );
session.save( e );
// run an HQL query to delete the association here, as well
------
Is this really the case? Do I understand what was written above correctly?
If this is the case, why would we have to drop down to HQL to manage something that other than this case, is fully managed by Hibernate?
Code: