ngkaka wrote:
1. Suppose it is "save-update" cascade, when saving the parent to the database, the children object would also be saved. The foreign key in the record representing the children data object in the children table points to the record representing the parent data object in the parent table.
But how about I save the children data object? Would the parent data object be saved? or only the children data object is saved? (but the foriegn key would be null?)
2. Suppose the children data object has been destroyed. Would the parent knows about it? or if I try to access the children data object from the reference in the set of the parent data object, null pointer excpetion?
3. Suppose the children data object has been "deleted" from the database, that is making the persistent instance transient. Would the parent knows about it? or if I try to access the children data object from the reference in the set of the parent data object, I can still play with the children object, although its record in the database has been deleted?
1. Parent data object will be saved if asked (<many-to-one cascade=save-update"/>)
2.<many-to-one> in the child object will tell hibernate to remove the link. However, if parent has been previously loaded, then you must manually update the parent collection in your java model. Have a look at the doc and at
http://www.hibernate.org/Documentation/InsideExplanationOfInverseTrue
3. Be more specific