2017-05-18 14 views
1

刪除用戶我收到的時候我試圖在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] 

這是我的域名:

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'] 
} 

}

我只是試圖創建一個沒有結果和測試的受訪者,但是當我刪除時,我得到這個錯誤..

有人可以幫忙嗎?謝謝

+0

你要怎麼刪除? – injecteer

+0

我使用腳手架默認方法刪除 – Ewyldor

回答

1

你想從USERS表中刪除一個數據,但在USER_ROLE表中它包含一個外鍵(名爲USER_ID)的USERS表。這就是爲什麼你無法刪除。根據USERS表ID刪除USER_ROLE表的數據,然後您可以刪除。

+0

謝謝!有用 ! – Ewyldor