So, you are saying set "int" to "0" . I actually followed the example given in
7.5 (Updating objects saved ......):
<id name="id" type="long" column="uid" unsaved-value="null">
Here the type is long, but int is similar, right?
The reason I did not follow the sample from 8.2 is: it requires to provide an parent id to save a child. If I try to save new parent and children at the
same time, parent id is unknown.
Any more thoughts?
I guess this:
You are using an "int" primitive for the identifer but set the unsaved value to "null". A primitive is never null, Hibernate can't decide if an instance is unsaved or not. Plese do us a favour and re-read the "parent/child relationship" chapter of the documentation. Half of your code is not neccessary, because you may cascade operations from department to students.