【发布时间】:2012-01-13 14:40:41
【问题描述】:
如何将对象添加到关系并保持它?
如果我这样做
registrationInstance.addToActionType(id:id)
我得到一个异常
Unique index or primary key violation: "PRIMARY_KEY_E7 ON PUBLIC.ACTION_TYPE_REGISTRATIONS(ACTION_TYPE_ID, REGISTRATION_ID)"; SQL statement: insert into action_type_registrations (action_type_id, registration_id) values (?, ?) [23001-147]
编辑:
如果我写
registrationInstance.addToActionType(ActionType.get(id))
我得到了同样的错误,但它仍然存在 - 那么我怎样才能摆脱这个错误呢?
EDIT2:
如果我尝试移除一个对象:
registrationInstance.removeFromActionType(ActionType.get(id))
我收到以下错误(有时,并非总是如此)
Eindeutiger Index oder Primarschlüssel verletzt: "PRIMARY_KEY_E7 ON PUBLIC.ACTION_TYPE_REGISTRATIONS(ACTION_TYPE_ID, REGISTRATION_ID)" Unique index or primary key violation: "PRIMARY_KEY_E7 ON PUBLIC.ACTION_TYPE_REGISTRATIONS(ACTION_TYPE_ID, REGISTRATION_ID)"; SQL statement: update action_type_registrations set action_type_id=? where registration_id=? and action_type_idx=? [23001-147]
【问题讨论】:
标签: hibernate grails grails-orm