【发布时间】:2013-11-22 08:34:07
【问题描述】:
当我尝试在静态脚手架中创建新员工时出现以下错误:
错误 500:内部服务器错误
URI /file-tracker/employee/save 类 org.hibernate.StaleStateException 消息 批量更新从更新 [0] 返回了意外的行数;实际行数:0;预计:1
第 38 行左右 grails-app/controllers/org/simpragma/EmployeeController.groovy
PageFragmentCachingFilter.java第191行左右
怎么了?
package org.xyz
class Employee {
String name;
String department;
String role;
String userId;
String pw;
static mapping = {
table 'employee'
version false
id name: 'userId'
id generator: 'native'
}
static hasMany = [toAllocations: Allocation, fromAllocations: Allocation]
static mappedBy = [toAllocations: 'toEmployee', fromAllocations: 'fromEmployee']
static constraints = {
department nullable : true
role nullable : true
}
}
package org.xyz
class Allocation {
static hasOne = [file:File, toEmployee:Employee, fromEmployee:Employee, remark:Remark]
static mappedBy = [toEmployee: 'toAllocations', fromEmployee: 'fromAllocations' ]
static constraints = {
remark nullable: true
}
}
package org.xyz
class File {
String fileNumber;
Date requestedDate;
String requestedBy;
String priority;
Double budget;
String requestedByDepartment;
String subject;
static mapping = {
id name: 'fileNumber'
version false
id generator: 'native'
}
static hasMany = [allocations: Allocation]
static constraints = {
fileNumber nullable : true
priority nullable : true
budget nullable : true
}
}
package org.xyz
class Remark {
String remark;
Date remarkDate;
static belongsTo = [allocation: Allocation];
static constraints = {
}
}
【问题讨论】:
标签: grails