我有一个类似的域
class BusinessOrganization {
static hasMany = [organizationBusinessTypes:OrganizationBusinessType]
String name
String icon
static constraints = {
name(blank:false,unique:true)
icon(unique:true)
}
String toString() {
return "${name}"
}
}
第一次保存时数据保存无误。但是当我第二次尝试保存时,我得到了这个错误:
Class java.sql.BatchUpdateException Message
Batch entry 0 insert into business_organization (version, icon, name, id) values ('0', '', '', '2') was aborted. Call getNextException to see the cause.
它说 :
def save() {
23: def businessOrganizationInstance = new BusinessOrganization(params)
24: if (!businessOrganizationInstance.save(flush: true)) {
25: render(view: "create", model: [businessOrganizationInstance: businessOrganizationInstance])
26: return
27: }
第 24 行出错。我无法弄清楚我做错了什么。在其他领域,这工作正常。请有人帮忙。我是 Grails 的新手,现在被困在这里。我正在使用 PostGreSQL