Unable to inherit hasMany property The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experiencePrefer composition over inheritance?how to upgrade from grails 1.2.2 to 1.3.7?Grails compile error java.lang.StringIndexOutOfBoundsException where upgrading from 2.0.1 to 2.0.2Grails 2.3.0 upgrade issue with windows slashesGrails 2.1.1 requires 'grails clean' before every 'grails run-app' — command line onlyGrails Console ErrorNo such property: developmentModeActive for class issue when run schema-exportdefaultGrailsBootstrapClass NPE during :bootRunIssue with xss-sanitizer plugin in grails 3.3.xGrails trying to use spring security
Huge performance difference of the command find with and without using %M option to show permissions
What happens to a Warlock's expended Spell Slots when they gain a Level?
Simulating Exploding Dice
Make it rain characters
Sub-subscripts in strings cause different spacings than subscripts
Homework question about an engine pulling a train
How to determine omitted units in a publication
Circular reasoning in L'Hopital's rule
Can the DM override racial traits?
Keeping a retro style to sci-fi spaceships?
What aspect of planet Earth must be changed to prevent the industrial revolution?
how can a perfect fourth interval be considered either consonant or dissonant?
Intergalactic human space ship encounters another ship, character gets shunted off beyond known universe, reality starts collapsing
Single author papers against my advisor's will?
My body leaves; my core can stay
Windows 10: How to Lock (not sleep) laptop on lid close?
A phrase ”follow into" in a context
How did passengers keep warm on sail ships?
Word for: a synonym with a positive connotation?
What do I do when my TA workload is more than expected?
Is 'stolen' appropriate word?
Store Dynamic-accessible hidden metadata in a cell
Why not take a picture of a closer black hole?
For what reasons would an animal species NOT cross a *horizontal* land bridge?
Unable to inherit hasMany property
The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experiencePrefer composition over inheritance?how to upgrade from grails 1.2.2 to 1.3.7?Grails compile error java.lang.StringIndexOutOfBoundsException where upgrading from 2.0.1 to 2.0.2Grails 2.3.0 upgrade issue with windows slashesGrails 2.1.1 requires 'grails clean' before every 'grails run-app' — command line onlyGrails Console ErrorNo such property: developmentModeActive for class issue when run schema-exportdefaultGrailsBootstrapClass NPE during :bootRunIssue with xss-sanitizer plugin in grails 3.3.xGrails trying to use spring security
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm currently migrating my grails code from version 2.5.6 to 3.3.9. On 3.3.9, I observed this weird behaviour:
There's an abstract class (in src/main/groovy) which contains a hasMany relationship.
package srcFolder
import grailsthree.TestSimpleClass
abstract class TestSuperClass
String superClassValue
static hasMany = [simples: TestSimpleClass]
A domain class which inherits this abstract class.
package grailsthree
import srcFolder.TestSuperClass
class TestSubClass extends TestSuperClass
String subClassValue
static constraints =
In the Bootstrap, call the addTo on the hasMany property of subclass,
package grailsthree
class BootStrap
def init = servletContext ->
TestSimpleClass testSimpleClass = new TestSimpleClass(simpleClassValue: 'simpleClassValue').save()
TestSubClass testSubClass = new TestSubClass(subClassValue: 'subClassValue')
testSubClass.addToSimples(testSimpleClass)
testSubClass.save()
def destroy =
Got following error:
groovy.lang.MissingMethodException: No signature of method: grailsthree.TestSubClass.addToSimples() is applicable for argument types: (grailsthree.TestSimpleClass) values: [grailsthree.TestSimpleClass : 1]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:71)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at grailsthree.BootStrap$_closure1.doCall(BootStrap.groovy:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1099)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:541)
at grails.util.Environment.executeForEnvironment(Environment.java:534)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:510)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:74)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:263)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:146)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at grailsthree.Application.main(Application.groovy:8)
Seems like on Grails 3.3.9, the sub-class is not inheriting the abstract class hasMany property. This is working fine for Grails 2.5.6.
Do we need to do any other handling in Grails 3.3.9 for this scenario?
inheritance grails gorm has-many
|
show 3 more comments
I'm currently migrating my grails code from version 2.5.6 to 3.3.9. On 3.3.9, I observed this weird behaviour:
There's an abstract class (in src/main/groovy) which contains a hasMany relationship.
package srcFolder
import grailsthree.TestSimpleClass
abstract class TestSuperClass
String superClassValue
static hasMany = [simples: TestSimpleClass]
A domain class which inherits this abstract class.
package grailsthree
import srcFolder.TestSuperClass
class TestSubClass extends TestSuperClass
String subClassValue
static constraints =
In the Bootstrap, call the addTo on the hasMany property of subclass,
package grailsthree
class BootStrap
def init = servletContext ->
TestSimpleClass testSimpleClass = new TestSimpleClass(simpleClassValue: 'simpleClassValue').save()
TestSubClass testSubClass = new TestSubClass(subClassValue: 'subClassValue')
testSubClass.addToSimples(testSimpleClass)
testSubClass.save()
def destroy =
Got following error:
groovy.lang.MissingMethodException: No signature of method: grailsthree.TestSubClass.addToSimples() is applicable for argument types: (grailsthree.TestSimpleClass) values: [grailsthree.TestSimpleClass : 1]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:71)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at grailsthree.BootStrap$_closure1.doCall(BootStrap.groovy:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1099)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:541)
at grails.util.Environment.executeForEnvironment(Environment.java:534)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:510)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:74)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:263)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:146)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at grailsthree.Application.main(Application.groovy:8)
Seems like on Grails 3.3.9, the sub-class is not inheriting the abstract class hasMany property. This is working fine for Grails 2.5.6.
Do we need to do any other handling in Grails 3.3.9 for this scenario?
inheritance grails gorm has-many
annotate you superclass with@grails.gorm.annotation.Entity
– injecteer
Mar 22 at 8:55
@injecteer I tried that as well, but it creates a table in the DB corresponding to my abstract super class. My main motive is to use this abstract class to inherit the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 9:34
creation of a table for the parent class and use of discriminator field --> this is how inheritance works in GORM. You can specify the explicittableName
inmapping...
though, but the discriminator_clazz
field will still be created in the table
– injecteer
Mar 22 at 10:26
@injecteer, yeah I get that. It's just that I don't want it to be treated as a domain class. As I mentioned, my intention to use this abstract class is for inheriting the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 11:10
you can create atrait
instead of a super class
– injecteer
Mar 22 at 11:28
|
show 3 more comments
I'm currently migrating my grails code from version 2.5.6 to 3.3.9. On 3.3.9, I observed this weird behaviour:
There's an abstract class (in src/main/groovy) which contains a hasMany relationship.
package srcFolder
import grailsthree.TestSimpleClass
abstract class TestSuperClass
String superClassValue
static hasMany = [simples: TestSimpleClass]
A domain class which inherits this abstract class.
package grailsthree
import srcFolder.TestSuperClass
class TestSubClass extends TestSuperClass
String subClassValue
static constraints =
In the Bootstrap, call the addTo on the hasMany property of subclass,
package grailsthree
class BootStrap
def init = servletContext ->
TestSimpleClass testSimpleClass = new TestSimpleClass(simpleClassValue: 'simpleClassValue').save()
TestSubClass testSubClass = new TestSubClass(subClassValue: 'subClassValue')
testSubClass.addToSimples(testSimpleClass)
testSubClass.save()
def destroy =
Got following error:
groovy.lang.MissingMethodException: No signature of method: grailsthree.TestSubClass.addToSimples() is applicable for argument types: (grailsthree.TestSimpleClass) values: [grailsthree.TestSimpleClass : 1]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:71)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at grailsthree.BootStrap$_closure1.doCall(BootStrap.groovy:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1099)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:541)
at grails.util.Environment.executeForEnvironment(Environment.java:534)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:510)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:74)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:263)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:146)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at grailsthree.Application.main(Application.groovy:8)
Seems like on Grails 3.3.9, the sub-class is not inheriting the abstract class hasMany property. This is working fine for Grails 2.5.6.
Do we need to do any other handling in Grails 3.3.9 for this scenario?
inheritance grails gorm has-many
I'm currently migrating my grails code from version 2.5.6 to 3.3.9. On 3.3.9, I observed this weird behaviour:
There's an abstract class (in src/main/groovy) which contains a hasMany relationship.
package srcFolder
import grailsthree.TestSimpleClass
abstract class TestSuperClass
String superClassValue
static hasMany = [simples: TestSimpleClass]
A domain class which inherits this abstract class.
package grailsthree
import srcFolder.TestSuperClass
class TestSubClass extends TestSuperClass
String subClassValue
static constraints =
In the Bootstrap, call the addTo on the hasMany property of subclass,
package grailsthree
class BootStrap
def init = servletContext ->
TestSimpleClass testSimpleClass = new TestSimpleClass(simpleClassValue: 'simpleClassValue').save()
TestSubClass testSubClass = new TestSubClass(subClassValue: 'subClassValue')
testSubClass.addToSimples(testSimpleClass)
testSubClass.save()
def destroy =
Got following error:
groovy.lang.MissingMethodException: No signature of method: grailsthree.TestSubClass.addToSimples() is applicable for argument types: (grailsthree.TestSimpleClass) values: [grailsthree.TestSimpleClass : 1]
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:71)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:53)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at grailsthree.BootStrap$_closure1.doCall(BootStrap.groovy:8)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1099)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at groovy.lang.Closure.call(Closure.java:412)
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:541)
at grails.util.Environment.executeForEnvironment(Environment.java:534)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:510)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:74)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:263)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:146)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
at grailsthree.Application.main(Application.groovy:8)
Seems like on Grails 3.3.9, the sub-class is not inheriting the abstract class hasMany property. This is working fine for Grails 2.5.6.
Do we need to do any other handling in Grails 3.3.9 for this scenario?
inheritance grails gorm has-many
inheritance grails gorm has-many
edited Mar 22 at 5:57
dev-eloper
asked Mar 22 at 5:50
dev-eloperdev-eloper
339
339
annotate you superclass with@grails.gorm.annotation.Entity
– injecteer
Mar 22 at 8:55
@injecteer I tried that as well, but it creates a table in the DB corresponding to my abstract super class. My main motive is to use this abstract class to inherit the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 9:34
creation of a table for the parent class and use of discriminator field --> this is how inheritance works in GORM. You can specify the explicittableName
inmapping...
though, but the discriminator_clazz
field will still be created in the table
– injecteer
Mar 22 at 10:26
@injecteer, yeah I get that. It's just that I don't want it to be treated as a domain class. As I mentioned, my intention to use this abstract class is for inheriting the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 11:10
you can create atrait
instead of a super class
– injecteer
Mar 22 at 11:28
|
show 3 more comments
annotate you superclass with@grails.gorm.annotation.Entity
– injecteer
Mar 22 at 8:55
@injecteer I tried that as well, but it creates a table in the DB corresponding to my abstract super class. My main motive is to use this abstract class to inherit the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 9:34
creation of a table for the parent class and use of discriminator field --> this is how inheritance works in GORM. You can specify the explicittableName
inmapping...
though, but the discriminator_clazz
field will still be created in the table
– injecteer
Mar 22 at 10:26
@injecteer, yeah I get that. It's just that I don't want it to be treated as a domain class. As I mentioned, my intention to use this abstract class is for inheriting the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 11:10
you can create atrait
instead of a super class
– injecteer
Mar 22 at 11:28
annotate you superclass with
@grails.gorm.annotation.Entity
– injecteer
Mar 22 at 8:55
annotate you superclass with
@grails.gorm.annotation.Entity
– injecteer
Mar 22 at 8:55
@injecteer I tried that as well, but it creates a table in the DB corresponding to my abstract super class. My main motive is to use this abstract class to inherit the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 9:34
@injecteer I tried that as well, but it creates a table in the DB corresponding to my abstract super class. My main motive is to use this abstract class to inherit the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 9:34
creation of a table for the parent class and use of discriminator field --> this is how inheritance works in GORM. You can specify the explicit
tableName
in mapping...
though, but the discriminator _clazz
field will still be created in the table– injecteer
Mar 22 at 10:26
creation of a table for the parent class and use of discriminator field --> this is how inheritance works in GORM. You can specify the explicit
tableName
in mapping...
though, but the discriminator _clazz
field will still be created in the table– injecteer
Mar 22 at 10:26
@injecteer, yeah I get that. It's just that I don't want it to be treated as a domain class. As I mentioned, my intention to use this abstract class is for inheriting the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 11:10
@injecteer, yeah I get that. It's just that I don't want it to be treated as a domain class. As I mentioned, my intention to use this abstract class is for inheriting the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 11:10
you can create a
trait
instead of a super class– injecteer
Mar 22 at 11:28
you can create a
trait
instead of a super class– injecteer
Mar 22 at 11:28
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293620%2funable-to-inherit-hasmany-property%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55293620%2funable-to-inherit-hasmany-property%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
annotate you superclass with
@grails.gorm.annotation.Entity
– injecteer
Mar 22 at 8:55
@injecteer I tried that as well, but it creates a table in the DB corresponding to my abstract super class. My main motive is to use this abstract class to inherit the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 9:34
creation of a table for the parent class and use of discriminator field --> this is how inheritance works in GORM. You can specify the explicit
tableName
inmapping...
though, but the discriminator_clazz
field will still be created in the table– injecteer
Mar 22 at 10:26
@injecteer, yeah I get that. It's just that I don't want it to be treated as a domain class. As I mentioned, my intention to use this abstract class is for inheriting the properties in the sub-domain classes.
– dev-eloper
Mar 22 at 11:10
you can create a
trait
instead of a super class– injecteer
Mar 22 at 11:28