重新加载子类时,我的webapp表现得很奇怪
package test
class Test {
Integer amount
//static mapping = {
// tablePerHierarchy true
// autoImport false
//}
}
和子类
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
我该如何解决问题?
答案 0 :(得分:1)
如果要对域类进行任何更改,则应重新启动应用程序。虽然它在您修改父类时工作正常,但动态域实体创建功能仍然无法正常工作。