wood burning stoves*
The moose likes Object Relational Mapping and the fly likes Simple But Crazy Cascade Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Simple But Crazy Cascade Problem" Watch "Simple But Crazy Cascade Problem" New topic
Author

Simple But Crazy Cascade Problem

Gokcen Guner
Greenhorn

Joined: May 23, 2009
Posts: 9
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?


UPDATE:

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.
 
 
subject: Simple But Crazy Cascade Problem
 
Similar Threads
detached entity passed to persist
org.hibernate.PropertyValueException: not-null property references a null or transient value:
[Hibernate Mysql 5 EJB3 JBoss] remove() foreign key constraint fails
Not-unique unique column
mapping One-to-many relationships using NetBeans and Not Hibernate