【发布时间】:2011-07-13 08:57:12
【问题描述】:
我有以下域类实体:
class AccountSupplier {
static mapping = {
table 'MY_TABLE'
version false
// references-column-mapping
accountReference: column:'REFACNTID'
supplierReference column:'REFSUPID'
// primary / foreign keys
id generator: 'assigned', column: 'REFACNTID'
id generator: 'assigned', column: 'REFSUPID'
}
Account accountReference
Supplier supplierReference
static constraints = {
accountReference(insert:false, update:false, nullable:false)
supplierReference(insert:false, update:false, nullable:false)
}
}
应该在 oracle 数据库中映射一个真实的表(已经存在并包含数千条记录。
当我想启动 grails 时,我得到以下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageSource': Initialization of bean failed; nested exception is 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: AccountSupplier column: REFSUPID (should be mapped with insert="false" update="false")
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.codehaus.groovy.grails.commons.spring.ReloadAwareAutowireCapableBeanFactory.doCreateBean(ReloadAwareAutowireCapableBeanFactory.java:105)
这有什么问题?我需要修改相关实体吗?我不能为主键创建外键吗?
谢谢
【问题讨论】:
标签: oracle grails grails-orm