I have a parent-child relationship similar to the one in Chapter 9 of the docs except my collection belongs to a component of the parent. The relation is bidirectional and mapped with inverse=false. When I do the following
Code:
//parent loaded in another session
Child child = new Child();
child.setParent(parent);
parent.getComponent().getChildren().add(child)
parent.setModified(new Date());
session.update(parent);
I get the following SQL generated
1. Insert of child into database. Good, just what I wanted.
2. Update of parent. Fine, due to setModified();
3. Update of another child in the collection that has not had anything modifed. The child being updated changes as i add more children to the collection but it is always one update and not several.
I cannot explain 3. As far as i can tell there are no side effects to any of the above calls that could cause this. i have checked all the values before and after the update and they are the same.
I am using latest hibernate version with postgresql.
thank you