重新加载子类时,我的Webapp行为异常
package test
class Test {
Integer amount
//static mapping = {
// tablePerHierarchy true
// autoImport false
//}
}
和 child 类
package test
class Test1 extends Test{
String cardNumber
}
重载父类后创建新表
但是如果我重新加载子类,grails控制台将引发错误
ERROR org.grails.plugins.AbstractGrailsPluginManager - Plugin [domainClass:3.0.9] could not reload changes to file [/home/gkiko/workspace/test/grails-app/domain/test/Test1.groovy]: Error creating bean with name 'org.grails.internal.SESSION_FACTORY_HOLDER-reloaded': Cannot create inner bean '(inner bean)#d22a35c' of type [org.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean] while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#d22a35c': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping test.Test1
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.grails.internal.SESSION_FACTORY_HOLDER-reloaded': Cannot create inner bean '(inner bean)#d22a35c' of type [org.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean] while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#d22a35c': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping test.Test1
.... some more stacktrace
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#d22a35c': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping test.Test1
我该如何解决该问题?
最佳答案
如果要对域类进行任何更改,则应重新启动应用程序。虽然在您修改父类的情况下可以正常工作,但是动态域实体创建功能仍然无法完美运行。
关于grails - gorm继承导致DuplicateMappingException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34811034/