Hi,
Hibernate version:3.0.5
I found that if I save an object with a unidirectonal toMany association I cannot remove an object from the association after save.
Here my dummy testcase:
Code:
User user = new User("test");
History h = new History();
user.addHistory(h);
dao.save(user);
user = dao.load("test");
assertTrue(1, user.getHistory().size());
//failed--->
assertTrue(user.removeHistory(user.getHistory().iterator.next()));
When I call Session.clear(); before dao.load(); it works.
I use a HashSet for the assoc. but after save the HashSet will be converted to a PersistentSet.
After debugging a see a comment in the class:
Code:
public PersistentSet(SessionImplementor session, java.util.Set set) {
super(session);
// Sets can be just a view of a part of another collection.
// do we need to copy it to be sure it won't be changing
// underneath us?
// ie. this.set.addAll(set);
this.set = set;
setInitialized();
setDirectlyAccessible(true);
}
Can anyone help?
Juergen