My guess is that it is failing because your Publisher still has Books belonging to it, so it is causing a foreign key constraint error in your database. That's what constraints are for - to stop you doing bad things by mistake
.
In general, you need to make sure that deleting the Publisher
cascades to the Books if you want them to be deleted at the same time. Maybe the problem is that your Publisher class does not know it has Books (although it should know this from the belongsTo declaration), so it does not know it has to delete them as well. Not sure why this would be the case, but you could try adding this to your Publisher class so it knows explicitly that it has Books: