I have a question about one-to-many collections. I have the following two classes.
Code:
<class name="Parent" table="parents">
<key>
<column name="parent_id", sql-type="char(36)"/>
</key>
<list name="children" inverse="true" cascade="all-delete-orphan">
<key>
<column name="parent_id" sql-type="char(36)"/>
</key>
<index column="index"/>
<one-to-many class="Child"/>
</list>
</class>
<class name="Child" table="children">
<key>
<column name="child_id" sql-type="char(36)"/>
</key>
<many-to-one name="parent" class="Parent">
<column name="parent_id" sql-type="char(36)" not-null="true"/>
</many-to-one>
</class>
Now for a Parent instance that had been saved in a previous session, I make some changes in a UI tier, like adding new Children, modifying some existing Children and removing some other exisiting Children from the Parent's children collection.
Now in order to saveOrUpdate() this Parent instance in a new Session, do I simply do session.saveOrUpdate( parent )? If so, will Hibernate know which Children are new, which ones modified and which ones to delete from the database?
Or would I have to manually iterate over the children collection in the dao tier to see which ones to saveOrUpdate and which ones to delete?
Thanks