Grails 我如何实施单向一对多关系?

Grails 我如何实施单向一对多关系?,grails,gorm,one-to-many,Grails,Gorm,One To Many,我有以下结构 class User { String fname String lname String email static constraints = { fname(nullable:true, maxSize:30) fname(nullable:true, maxSize:30) email(nullable: true, email: true) } } class A exten

我有以下结构

 class User {

     String fname
     String lname
     String email

     static constraints = {
       fname(nullable:true, maxSize:30)
       fname(nullable:true, maxSize:30)
       email(nullable: true, email: true)
     }
}

class A extends User{
    String smtng
    List bInstance = new ArrayList()

    static hasMany = [b : B] 

    static constraints = {
       smtng(blank : true)
       b(nullable : true)
    }
}

class B {
    String smtng1
    String smtng2

    static constraints = {
       smtng1(blank:true, maxSize:50)
       smtng2(blank:true, maxSize:50)
    }
}
当我尝试运行此代码时,它显示以下错误

完整堆栈跟踪

    2014-09-03 12:37:11,010 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:70)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.establishRelationshipForCollection(DefaultGrailsDomainClass.java:362)
    at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.establishRelationships(DefaultGrailsDomainClass.java:262)
    at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.<init>(DefaultGrailsDomainClass.java:120)
    at org.codehaus.groovy.grails.commons.DomainClassArtefactHandler.newArtefactClass(DomainClassArtefactHandler.java:54)
    at org.codehaus.groovy.grails.commons.AnnotationDomainClassArtefactHandler.newArtefactClass(AnnotationDomainClassArtefactHandler.java:54)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:812)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:538)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.configureLoadedClasses(DefaultGrailsApplication.java:259)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialise(DefaultGrailsApplication.java:743)
    at org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean.afterPropertiesSet(GrailsPluginManagerFactoryBean.java:123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
    ... 23 more
2014-09-03 12:37:11,015 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.establishRelationshipForCollection(DefaultGrailsDomainClass.java:362)
    at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.establishRelationships(DefaultGrailsDomainClass.java:262)
    at org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.<init>(DefaultGrailsDomainClass.java:120)
    at org.codehaus.groovy.grails.commons.DomainClassArtefactHandler.newArtefactClass(DomainClassArtefactHandler.java:54)
    at org.codehaus.groovy.grails.commons.AnnotationDomainClassArtefactHandler.newArtefactClass(AnnotationDomainClassArtefactHandler.java:54)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:812)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:538)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.configureLoadedClasses(DefaultGrailsApplication.java:259)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialise(DefaultGrailsApplication.java:743)
    at org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean.afterPropertiesSet(GrailsPluginManagerFactoryBean.java:123)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:70)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
2014-09-03 12:37:11,018 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    ... 5 more
2014-09-03 12:37:11,020 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    ... 5 more
2014-09-03 12:37:11,022 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
2014-09-03 12:37:11,023 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    ... 5 more
2014-09-03 12:37:11,024 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    ... 5 more
2014-09-03 12:37:11,026 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
2014-09-03 12:37:11,027 [localhost-startStop-1] ERROR StackTrace  - Full Stack Trace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.codehaus.groovy.grails.exceptions.GrailsDomainException: Property [b] in class [class A] is a bidirectional one-to-many with two possible properties on the inverse side. Either name one of the properties on other side of the relationship [a] or use the 'mappedBy' static to define the property that the relationship is mapped with. Example: static mappedBy = [b:'myprop']
    ... 5 more
2014-09-03 12:37:11010[localhost-startStop-1]错误堆栈跟踪-完整堆栈跟踪:
org.springframework.beans.factory.BeanCreationException:使用ServletContext资源[/WEB-INF/applicationContext.xml]中定义的名称“pluginManager”创建bean时出错:调用init方法失败;嵌套的异常是org.codehaus.groovy.grails.exceptions.GrailsDomainException:class[class A]中的属性[b]是双向的一对多,其反面有两个可能的属性。命名关系另一端的一个属性[a],或使用“mappedBy”静态定义映射关系的属性。示例:静态mappedBy=[b:'myprop']
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
位于org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
位于org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
位于org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
位于org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:610)
位于org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
位于org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
位于org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
位于org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
位于org.codehaus.groovy.grails.web.context.GrailContextLoader.initWebApplicationContext(grailContextLoader.java:70)
位于org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
位于org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
位于org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
位于org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
位于org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
位于org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
位于java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
位于java.util.concurrent.FutureTask.run(FutureTask.java:138)
位于java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
运行(Thread.java:662)
由:org.codehaus.groovy.grails.exceptions.GrailsDomainException引起的:类[class A]中的属性[b]是双向的一对多,其反面有两个可能的属性。命名关系另一端的一个属性[a],或使用“mappedBy”静态定义映射关系的属性。示例:静态mappedBy=[b:'myprop']
位于org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.EstablisationshipForCollection(DefaultGrailsDomainClass.java:362)
位于org.codehaus.groovy.grails.commons.DefaultGrailDomainClass.establishRelationships(DefaultGrailDomainClass.java:262)
位于org.codehaus.groovy.grails.commons.DefaultGrailDomainClass。(DefaultGrailDomainClass.java:120)
位于org.codehaus.groovy.grails.commons.DomainClassArtefactHandler.newArtefactClass(DomainClassArtefactHandler.java:54)
位于org.codehaus.groovy.grails.commons.AnnotationDomainClassArtefactHandler.newArtefactClass(AnnotationDomainClassArtefactHandler.java:54)
位于org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:812)
位于org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:538)
位于org.codehaus.groovy.grails.commons.DefaultGrailsApplication.configureLoadedClasses(DefaultGrailsApplication.java:259)
位于org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialise(DefaultGrailsApplication.java:743)
位于org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean.AfterPropertieSet(GrailsPluginManagerFactoryBean.java:123)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 23多
2014-09-03 12:37:11015[localhost-startStop-1]错误堆栈跟踪-完整堆栈跟踪:
org.codehaus.groovy.grails.exceptions.GrailsDomainException:class[class A]中的属性[b]是双向的一对多,其反面有两个可能的属性。命名关系另一端的一个属性[a],或使用“mappedBy”静态定义映射关系的属性。示例:静态mappedBy=[b:'myprop']
位于org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass.EstablisationshipForCollection(DefaultGrailsDomainClass.java:362)
位于org.codehaus.groovy.grails.commons.DefaultGrailsDom
class A extends User{
   String smtng
   List bInstance

   static hasMany = [bInstance : B] 

   static constraints = {
      bInstance(nullable : true)
   }
}

class B {
  String smtng1
  String smtng2

  static belongsTo = [A]
}
class A extends user{
  static hasMany = [bInstance : B] 
  static mappedBy = [ B:'bref' ]
}
class B {
  static belongsTo = [ a:A ]
}
class A extends User{
    String smtng
    List b // note: do not include an initializer expression here

    static hasMany = [b : B]

    static mappedBy = [b:"none"]

    static constraints = {
       smtng(blank : true)
       b(nullable : true)
    }
}