2011-05-29 65 views
1

我正在嘗試將Grails 1.0.3項目升級到1.3.7,並且有我認爲是相關的問題。Grails 1.0.3升級問題

舊的項目在conf/hibernate/Domain1.hbm.xml中有Hibernate的xml文件我猜測GORM在1.0.3中不存在?

我需要轉換本質是什麼在XML文件轉換成Groovy代碼中域類域/

任何其他細節是有益的。謝謝。

更新 -

所有這些變化都是org.hibernate.DuplicateMappingException它看起來像我可以只移動域文件的結果:Relevant Post這真的是我想要做雖然?我的理解是,對於GORM,我根本不需要使用xml文件。

這裏有一個例外

2011-05-29 16:43:49,616 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: 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.DuplicateMappingException: Duplicate class/entity mapping sportsdb.Event 
    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.DuplicateMappingException: Duplicate class/entity mapping sportsdb.Event 
     at org.grails.tomcat.InlineExplodedTomcatServer.doStart(InlineExplodedTomcatServer.groovy:112) 
     at org.grails.tomcat.InlineExplodedTomcatServer$doStart.callCurrent(Unknown Source) 
     at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:97) 
     at grails.web.container.EmbeddableServer$start.call(Unknown Source) 
     at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158) 
     at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy) 
     at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280) 
     at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy) 
     at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149) 
     at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy) 
     at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116) 
     at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy) 
     at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59) 
     at RunApp$_run_closure1.doCall(RunApp:33) 
     at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) 
     at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) 
     at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) 
     at gant.Gant.withBuildListeners(Gant.groovy:427) 
     at gant.Gant.this$2$withBuildListeners(Gant.groovy) 
     at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) 
     at gant.Gant.dispatch(Gant.groovy:415) 
     at gant.Gant.this$2$dispatch(Gant.groovy) 
     at gant.Gant.invokeMethod(Gant.groovy) 
     at gant.Gant.executeTargets(Gant.groovy:590) 
     at gant.Gant.executeTargets(Gant.groovy:589) 
    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.DuplicateMappingException: Duplicate class/entity mapping sportsdb.Event 
     ... 25 more 
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: Duplicate class/entity mapping sportsdb.Event 
     ... 25 more 
    Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping sportsdb.Event 
     ... 25 more 

回答

3

GORM Grails的1.0.3肯定存在。

您可能只需更新1.3.7的hibernate配置。看看Grails and Hibernate - Reference Documentation

除非您映射到遺留或其他不尋常的數據庫模式,否則標準的GORM域建模是一條可行的路線。它非常靈活。

+0

@JamesA - 感謝您的鏈接和信息。但是,與鏈接相比,hibernate xml看起來很好,所以我不確定。任何其他想法? – skaz 2011-05-29 20:49:25

+0

@JamesA - 我相信我需要有hibernate xml和將會有函數擴展它們的域對象。它似乎只是不喜歡,我都有。 – skaz 2011-05-29 21:00:35

+0

是的,你需要conf/hibernate中的映射文件和src/java中的域類。 – jamesallman 2011-05-29 21:09:01