tags:

views:

77

answers:

2

i have one class called course and one class called tutorials in class i hav set of tutorials .Wnen i delete course i want all tutorials associaed with that course to be deleted . But presently the tutorials are not geting deleted when i delete the owner course only the foreign key courseid in tutorials tables becomes null;

i am using folloing code cascade="delete-orphan,all" inverse= "true" in course.hhm.xml

when i am deleting

A: 

Try

cascade="all-delete-orphan"
FoxyBOA
A: 

Note that the "orphan" part doesn't have anything to do with cascading the deletion of a course to that of the tutorials, it allows

c.getTutorials().remove(tutorialToDelete);
session.merge( c );

to delete the tutorial that was removed in the collection instance, I don't know if there are performance issues associated with the orphan flag, but if you don't rely on that behavior you may just want to switch it to

cascade="delete"
walnutmon