Hibernate version: 3.2.1
Mapping documents:
Code:
@ManyToMany(targetEntity = Van.class, cascade={CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
@JoinTable(name = "employees_vans", joinColumns = @JoinColumn(name="employee_id", referencedColumnName="employee_id"), inverseJoinColumns= @JoinColumn(name="van_id", referencedColumnName="van_id"))
public List<Van> getVans() {
return vans;
}
Code:
@ManyToMany(targetEntity = Employee.class, mappedBy = "vans", cascade={CascadeType.PERSIST, CascadeType.MERGE})
public List<Employee> getEmployees() {
return employees;
}
Name and version of the database you are using: Derby 10.1.3.1
I am having trouble with the above many-to-many association.
When I remove a van from a employee using the following...
Code:
employee.getVans().remove(van);
van.getEmployees().remove(employee);
...then save the change with the following, the changes to the to collections are not flushed the database. (I am commting the transaction and still no flush.)
Code:
session.saveOrUpdate(employee);
But when I change a property of the Employee class in addition to the collections, then the changes to the to collections are flushed the database.
Code:
employee.setName("Change Name");
What could cause hibernate to ignore the changes to the collections in the example where I did not change the name property?