aspose file tools
The moose likes Object Relational Mapping and the fly likes Simple But Crazy Cascade Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply 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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Simple But Crazy Cascade Problem
 
Similar Threads
mapping One-to-many relationships using NetBeans and Not Hibernate
Not-unique unique column
detached entity passed to persist
[Hibernate Mysql 5 EJB3 JBoss] remove() foreign key constraint fails
org.hibernate.PropertyValueException: not-null property references a null or transient value: