Rob Spoor wrote:If you don't specify any cascade actions explicitly, no action is cascaded. That means that your Address will not be stored in the database, and that in turn would mean the Student would lose its reference. Instead, an exception is thrown, so you're made aware that you made a mistake.
Possible solutions:
- Persist the Address object manually before you set it on the Student object.
- Add at least PERSIST as cascade action on the Student side of the relationship. That way, whenever a Student's Address is not persisted, this will be done automagically.
Got it. But when Address is not saved and Student loses reference, does it affect saving *other* attributes (like student name, etc) of "Student" ? i.e. would the entire saving of "Student" object fail, or just miss the part of saving Address and reference to address ?