Hi everyone!
The situation that I am encountering is that I need to remove a record associated with another record when that record is set to null. To be a bit more clear, here is an example. I have a Person object which contains a Phone object (PERSON table references PHONE_ID from the PHONE table). When the Phone object is set to null in the Person object, I need the Phone record to be removed from the database when the Person object is saved. But what actually happens is that only the PHONE_ID from the PERSON table gets removed, but the actual phone record is still in the database.
The following is what I have inside my mapping for the Person object:
Code:
<many-to-one name="phone" class="Phone" cascade="all">
<column name="PHONE_ID" />
</many-to-one>
I tried using a one-to-one relationship but this doesn't seem to work either. Any suggestions?
Thanks in advance!