Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Duplicate
-
Affects Version/s: 1.3.5, 1.3.6, 1.3.7, 1.3.8
-
Fix Version/s: 2.0 final
-
Component/s: Persistence
-
Labels:None
-
Environment:kubuntu 10.04, jbm 1.6.20, grails 1.3.5
Description
When having an inheritance structure similiar to the one in the attached project:
Book extends Literature
Magazine extends Literature
Owner has reference to a Literature
When the Literature Domain Class is abstract there are 2 Problems.
- even if the it defines
static mapping = { tablePerHierarchy false }
in the Mapping DSL it ignores it and adds the fields of Literature to the Tables of the Sub-Klasses.
No Table for the abstract Litrature Class.
Am I wrong in expecting it to behave similiar to the case the Literature wouldn't be abstract. - If I have a reference to such an abstract domain class from another domain class i get the following MappingException.
Am I wrong in beliving this should be a possible implementation ?
What is the right way to implement such a construct in Grails (SuperClass should not be instantiable but referenceable).
I attached an simple made up sample project which comes up with the Exception on startup. You can either remove the abstract keyword from Literature or the Reference from Owner to Literature to make the app start.
[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.MappingException: An association from the table owner refers to an unmapped class: library.Literature 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: An association from the table owner refers to an unmapped class: library.Literature at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212) at grails.web.container.EmbeddableServer$start.call(Unknown Source) 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 _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:263) at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy) at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:299) at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy) at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:245) at RunApp$_run_closure1.doCall(RunApp.groovy:35) 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.MappingException: An association from the table owner refers to an unmapped class: library.Literature ... 29 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: An association from the table owner refers to an unmapped class: library.Literature ... 29 more Caused by: org.hibernate.MappingException: An association from the table owner refers to an unmapped class: library.Literature ... 29 more Application context shutting down...
I am also running into this issue. Affects 1.3.4 as well.