本文介绍了如何解决Grails错误实体映射中的重复列?在现有的PostgreSQL数据库上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我在Grails中拥有以下域:
class Customer {
static mapping = {
table'客户'
//版本设置为false,因为旧数据库默认不可用
版本false
id列:'customerid'//生成器:'identity',
}
长客户
长客户组ID
字符串用户名
字符串密码
字符串名称
字符串街道
字符串城市
字符串省
字符串邮政编码
字符串国家
日期dateregistered
字符串余额
长字符
字符串parentrebate
字符串元字符路径
长metalevel
整数smsreplystatus
整数状态
字符串反转
$ b静态约束= {
customerid(insert:false,update:false)
customergroupid(最大:9999999999L)
使用rname(大小:1..20,空白:假)
密码(大小:1..32,空白:假)
名称(大小:1..20,空白:假)
街道(大小:0..50)
城市(大小:0..20)
省份(大小:0..20)
邮编(大小:0..5)
国家(大小:0..20)
dateregistered(可空:true)
余额()
parentid(最大值:9999999999L)
parentrebate()
metalevel(max:9999999999L)
smsreplystatus(max:99999)
状态(最大值:99999)
reversalurl(尺寸:1..255,空白:false)
metalevel :0..50)
}
String toString(){
return$ {customerid}
}
}
我现有的数据库包含现有的数据,并且已经用GRAG映射到GORM,但是我收到了这个错误
导致:org.springframework.beans.factory.BeanCreationException:创建名为'transactionMa的Bean时出错nager':在设置bean属性'sessionFactory'时无法解析对bean'sessionFactory'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是org.hibernate.MappingException:实体映射中的重复列:postgresql.Customer列:customerid(应该使用insert =falseupdate =false映射)
... 23 more
由于:org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:init方法的调用失败;嵌套异常是org.hibernate.MappingException:实体映射中的重复列:postgresql.Customer列:customerid(应该使用insert =falseupdate =false映射)
解决方案
同样的问题,删除长customerid
这可能不是一个可行的解决方案,但至少应用程序编译并创建表。
根本没有调查,因为我只是设法得到这个工作 - 也许设置自定义标识列时,该属性的定义是隐含的(因此重复列...错误)
Hi i have this following Domain in Grails
class Customer { static mapping = { table 'customer' // version is set to false, because this isn't available by default for legacy databases version false id column:'customerid' //generator:'identity', } Long customerid Long customergroupid String username String password String name String street String city String province String postcode String country Date dateregistered String balance Long parentid String parentrebate String metapath Long metalevel Integer smsreplystatus Integer status String reversalurl static constraints = { customerid(insert:false,update:false) customergroupid(max: 9999999999L) username(size: 1..20, blank: false) password(size: 1..32, blank: false) name(size: 1..20, blank: false) street(size: 0..50) city(size: 0..20) province(size: 0..20) postcode(size: 0..5) country(size: 0..20) dateregistered(nullable: true) balance() parentid(max: 9999999999L) parentrebate() metapath(size: 1..255, blank: false) metalevel(max: 9999999999L) smsreplystatus(max: 99999) status(max: 99999) reversalurl(size: 0..50) } String toString() { return "${customerid}" } }
i have current database with existing data, and has mapping to GORM with GRAG but i'm getting this error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: postgresql.Customer column: customerid (should be mapped with insert="false" update="false") ... 23 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: postgresql.Customer column: customerid (should be mapped with insert="false" update="false")
解决方案
Had same problem, remove "Long customerid"
This may not be a workable solution but at least the app compiles and creates the table.
Have not investigated at all as I just managed to get this working -- perhaps when setting a custom identity column, the property definition is implied (thus the "repeated column..." error)
这篇关于如何解决Grails错误实体映射中的重复列?在现有的PostgreSQL数据库上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!