I have a User table that has many child tables defined in the User class under static hasMany Grails.
I have no problem executing User.get (3) .delete () in grails. It automatically deletes this user and all its child tables. But when I want to perform the same operation in MySQL workbench. I get a MySQL error message:
ERROR 1451: Cannot delete or update a parent row: a foreign key constraint fails (`test_db`.`search_stat`, CONSTRAINT `FK7A3CFFB6E64DB41` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`))
SQL Statement:
DELETE FROM `test_db`.`user` WHERE `id`='3'
I do not know what the problem is with MySQL.
source
share