我有一个简单的域对象。Grails GORM绑定域两次
class Product {
public static final String TRACE_SKU="236"
Integer xRefId
static constraints = {
xRefId(nullable:true)
}
static mapping = {
table 'product'
version false
id generator:'identity', column:'id'
xRefId column:'xref_id'
cache usage: 'nonstrict-read-write'
}
}
我在应用程序启动时以及运行测试用例时收到以下错误。
Repeated column in mapping for entity: com.appdroplet.tricor.common.domain.product.Product column: xref_id (should be mapped with insert="false" update="false")
此外,当我检查错误日志时,我看到此消息。
[ 15.11.16 09:34:50.403] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] Mapping Grails domain class: com.appdroplet.tricor.common.domain.product.Product -> product
[ 15.11.16 09:34:50.403] [main] [DEBUG] [org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory] Returning cached instance of singleton bean 'orgGrailsBeansConstraintsEvaluator'
[ 15.11.16 09:34:50.405] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] bound property [id] to column name [id] in table [product]
[ 15.11.16 09:34:50.405] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] Binding persistent property [XRefId]
[ 15.11.16 09:34:50.405] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] Binding property [XRefId] as SimpleValue
[ 15.11.16 09:34:50.407] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] bound property [XRefId] to column name [xref_id] in table [product]
[ 15.11.16 09:34:50.407] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] Binding persistent property [xRefId]
[ 15.11.16 09:34:50.407] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] Binding property [xRefId] as SimpleValue
[ 15.11.16 09:34:50.407] [main] [DEBUG] [org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder] [GrailsDomainBinder] bound property [xRefId] to column name [xref_id] in table [product]
由于某些原因,Grails将两次绑定属性相同。
项目正在使用Grails 2.3.0
如果删除'xRefId柱发生了什么:“xref_id''? – injecteer
它在映射上没有错误,但它似乎绑定了两个属性:表[product]中的'bound property [XRefId]到表名[xref_id]'和表[product中的绑定属性[xRefId]到列名[x_ref_id] ]' – mfleshman
将字段重命名为“xrefId”是个问题吗? – injecteer