Thankss,
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">
....
</id>
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?
regards,
christian wrote:
I guess this:
DbService.saveDepartment(dept);
and this
DbService.saveStudent(st);
calls Session.saveOrUpdate()?
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.