I'm getting this error when I'm trying to delete a Interviewee in the GORM :
Referential integrity constraint violation: "FK_APCC8LXK2XNUG8377FATVBN04:
PUBLIC.USER_ROLE FOREIGN KEY(USER_ID) REFERENCES PUBLIC.USERS(ID) (40)";
SQL statement: delete from users where id=? and version=? [23503-176]
And this is my domain :
package com.cgi.recruitmenttest
import com.cgi.security.User
class Interviewee extends User{
String firstName
String lastName
String email
String telephone
String level
static hasMany = [results:Result,tests:TestInterviewe]
static constraints = {
lastName()
firstName()
email(email: true)
telephone(nullable: true)
level inList: ['Debutant', 'Confirme', 'Expert']
}
}
I just try to create a interviewee without results and tests but when I delete, i get this error..
Can someone help ? Thanks
You want to delete a data from USERS
table but in USER_ROLE
table it contained a foreign key (named USER_ID) of USERS
table. That's why you are unable to delete. Delete USER_ROLE
table's data first according USERS
table ID then you may able to delete.