作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有几个具有子级父级关系的类,但是,当尝试保存所有内容时,Grails GORM首先保存该子级,最终抛出以下错误:
ORA-02291: integrity constraint violated - parent key not found
class Request
{
// Mapping definitions
static mapping = {
table(name: 'FORMS_REQUEST')
tablePerHierarchy(false)
id(length: 20, precision: 20, scale: 0, generator: 'sequence', params: [sequence: 'FORMS_REQUEST_SEQ'])
}
// Properties
Timestamp version
Form form
Date submittedTime
}
abstract class Form
{
// Mapping definitions
static mapping = {
table(name: 'FORMS_FORM')
tablePerHierarchy(false)
id(length: 20, precision: 20, scale: 0, generator: 'sequence', params: [sequence: 'FORMS_FORM_SEQ'])
}
// Relationship definitions
static belongsTo = [request: Request]
// Properties
Timestamp version
}
class AccessForm extends Form
{
// Mapping definitions
static mapping = {
table(name: 'FORMS_ACCESS_FORM')
id(length: 20, precision: 20, scale: 0, generator: 'sequence', params: [sequence: 'FORMS_ACCESS_FORM_SEQ'])
}
// Relationship definitions
static hasMany = [adGroups: AccessFormAD, printers: AccessFormPrinter]
// Properties
List adGroups
List printers
}
class AccessFormAD
{
// Mapping definitions
static mapping = {
table(name: 'FORMS_ACCESS_FORM_AD')
id(length: 20, precision: 20, scale: 0, generator: 'sequence', params: [sequence: 'FORMS_ACCESS_FORM_AD_SEQ'])
}
// Relationship definitions
static belongsTo = [accessForm: AccessForm]
// Properties
Timestamp version
}
class AccessFormPrinter
{
// Mapping definitions
static mapping = {
table(name: 'FORMS_ACCESS_FORM_PRINTER')
id(length: 20, precision: 20, scale: 0, generator: 'sequence', params: [sequence: 'FORMS_ACCESS_FORM_PRINTER_SEQ'])
}
// Relationship definitions
static belongsTo = [accessForm: AccessForm]
// Properties
Timestamp version
}
request.save(flush: true)
Hibernate: select FORMS_REQUEST_SEQ.nextval from dual
Hibernate: select FORMS_FORM_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: select FORMS_ACCESS_FORM_AD_SEQ.nextval from dual
Hibernate: insert into FORMS_ACCESS_FORM_AD (version, checked, DN, type, access_form_id, ad_groups_idx, id) values (?, ?, ?, ?, ?, ?, ?)
Sep. 02 2014 @ 03:58:06 PM - class spi.SqlExceptionHelper - ORA-02291: integrity constraint (FK_954TU4QUPD4QE7H72XGVXSTKV) violated - parent key not found
最佳答案
问题在于,您的Request
域类正在对相关的Form
使用简单的属性分配。
因此,您需要使用Form form
而不是static hasOne = [form:Form]
来定义该关系。
原因是GORM通过使用hasOne
和hasMany
之类的东西来确定关系,进而可以确定需要插入什么顺序。
关于hibernate - Grails GORM-在 parent 之前救助 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25631852/
我正在尝试在两个节点群集上运行mapreduce作业。我收到以下错误 随机播放错误:超过MAX_FAILED_UNIQUE_FETCHES;纾困。 我通读了一些帖子,说这是由于/ etc / host
我是一名优秀的程序员,十分优秀!