Hi there! I need some help understanding something/getting it to work. In a previous post (http://www.coderanch.com/t/217070/ORM/java/Hibernate-one-many), I was having a hard time understanding how to get one-to-many collections to work. Thanks to your help, I managed to figure it out. Now, I'm trying to figure out how to delete the collections (and then the parent). Now. What I fiugure, is when you have a parent, with children in a one-to-many relationship, and having cascade set to "all-delete-cascade", when you delete the parent, it should cascade over and delete the children also.
But that doesn't seem to be the case. I just get a foeign key error.
So. I figure I must delete the children first! But how...
I have 2.5 classes: a Doctor class, and an Appointment class. Doctors have appointments.
Here's the Doctor class:
...and here's the Appointment Class:
...and because I'm neurotic (or a good developer, I have a subclass called DoctorsApointment. It just creates an instance of Doctor, and it's getter and setters.
Finally, here's my code where I attempt to delete what I created:
Now... What I'm trying to do, is first delete all the appointments, then the doctor. When I run it, I still get a "MySQLIntegerityConstraintVoiletingException", which is bascially telling me I'm voilating the relationship by deleting the doctor.