Although I'm using javax.persistence.CascadeType.ALL, org.hibernate.annotations.CascadeType.ALL, and OnDeleteAction.CASCADE I couldn't manage to delete parent row.
My code is like that:
I have one base class Person and 2 inherited classes Doctor and Patient. One doctor can have one or more patients but a patient is related to only one doctor. That is so simple. But for hours I couldn't delete a doctor that have patients referencing on it. I want the patients to be deleted when their doctor is deleted.
The exception trace is:
What I need to do? I'm using all deletion cascades, orphan removal etc.
Please tell me the problem. It must work, isn't it?
I've looked at the generated schema:
with the mapping for these annotation configuration:
As you see hibernate is aware of foreign keys PERSON_USER_FK and PATIENT_DOCTOR_FK but doesn't generate Cascade statements. I will go mad please help me.
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss