Many-to-many bug ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Many-to-many bug ?

OlivierD
Hello,

We found a strange bug in a many-to-many relation. Here is how to reproduce from the example
from the doc :

=========================================
class Author {
    static hasMany = [books:Book]
    static mappedBy = [books:"authors"]

    String name
}
=========================================
class Book {
    static belongsTo = Author
    static hasMany = [authors:Author]
    static mappedBy = [authors:"books"]

    String title
}
=========================================

All is ok like this.

Now if I try to add a field with the type Book in class Author :

1. if the field name start with book... like in

=========================================
class Author {
    static hasMany = [books:Book]
    static mappedBy = [books:"authors"]

    String name
    Book bookOther
}
=========================================

, it fails immediately with the exception :

2007-10-09 14:51:34.141::WARN:  Nested in 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 fa
iled; nested exception is java.lang.NullPointerException:
java.lang.NullPointerException
        at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.linkBidirectionalOneToMany(GrailsDomainBinder.java:420)
        at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindCollectionSecondPass(GrailsDomainBinder.java:296)
        at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.access$100(GrailsDomainBinder.java:52)
        at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder$GrailsCollectionSecondPass.doSecondPass(GrailsDomainBinder.java:156)
        at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
        at org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.secondPassCompile(DefaultGrailsDomainConfiguration.java:95)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:804)
        at org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.newSessionFactory(ConfigurableLocalSessionFactoryBean.java:87)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:744)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:245)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:124)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1019)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
        at org.codehaus.groovy.grails.orm.support.TransactionManagerPostProcessor.postProcessBeanFactory(TransactionManagerPostProcessor.java:42)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:314)
        at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:90)
        at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:261)
        at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:232)
        at org.codehaus.groovy.grails.commons.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:103)
        at org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:35)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
        at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)

2. if the field name don't start with book, it is ok.

Even more strange, in our real project, with any name, it fails...

It seems to be a bug. Could you confirm this ?
Do I have to add it to JIRA ?

Thanks,

Olivier

PS: We are using grails version 0.6 on Windows XP.
Reply | Threaded
Open this post in threaded view
|

Re: Many-to-many bug ?

graemer
Raise an issue please

Cheers

On 10/9/07, OlivierD <[hidden email]> wrote:

>
> Hello,
>
> We found a strange bug in a many-to-many relation. Here is how to reproduce
> from the example
> from the doc :
>
> =========================================
> class Author {
>     static hasMany = [books:Book]
>     static mappedBy = [books:"authors"]
>
>     String name
> }
> =========================================
> class Book {
>     static belongsTo = Author
>     static hasMany = [authors:Author]
>     static mappedBy = [authors:"books"]
>
>     String title
> }
> =========================================
>
> All is ok like this.
>
> Now if I try to add a field with the type Book in class Author :
>
> 1. if the field name start with book... like in
>
> =========================================
> class Author {
>     static hasMany = [books:Book]
>     static mappedBy = [books:"authors"]
>
>     String name
>     Book bookOther
> }
> =========================================
>
> , it fails immediately with the exception :
>
> 2007-10-09 14:51:34.141::WARN:  Nested in
> 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 fa
> iled; nested exception is java.lang.NullPointerException:
> java.lang.NullPointerException
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.linkBidirectionalOneToMany(GrailsDomainBinder.java:420)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindCollectionSecondPass(GrailsDomainBinder.java:296)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.access$100(GrailsDomainBinder.java:52)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder$GrailsCollectionSecondPass.doSecondPass(GrailsDomainBinder.java:156)
>         at
> org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.secondPassCompile(DefaultGrailsDomainConfiguration.java:95)
>         at
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
>         at
> org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:804)
>         at
> org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.newSessionFactory(ConfigurableLocalSessionFactoryBean.java:87)
>         at
> org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:744)
>         at
> org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
>         at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:245)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:124)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1019)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
>         at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
>         at
> org.codehaus.groovy.grails.orm.support.TransactionManagerPostProcessor.postProcessBeanFactory(TransactionManagerPostProcessor.java:42)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:314)
>         at
> org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:90)
>         at
> org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:261)
>         at
> org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:232)
>         at
> org.codehaus.groovy.grails.commons.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:103)
>         at
> org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:35)
>         at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
>         at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
>         at
> org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
>         at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
>         at
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
>         at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
>
> 2. if the field name don't start with book, it is ok.
>
> Even more strange, in our real project, with any name, it fails...
>
> It seems to be a bug. Could you confirm this ?
> Do I have to add it to JIRA ?
>
> Thanks,
>
> Olivier
>
> PS: We are using grails version 0.6 on Windows XP.
> --
> View this message in context: http://www.nabble.com/Many-to-many-bug---tf4594097.html#a13115160
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: Many-to-many bug ?

OlivierD
Thanks. Done.
JIRA 1686.

Olivier

graemer wrote
Raise an issue please

Cheers

On 10/9/07, OlivierD <olivier.duchene@gmail.com> wrote:
>
> Hello,
>
> We found a strange bug in a many-to-many relation. Here is how to reproduce
> from the example
> from the doc :
>
> =========================================
> class Author {
>     static hasMany = [books:Book]
>     static mappedBy = [books:"authors"]
>
>     String name
> }
> =========================================
> class Book {
>     static belongsTo = Author
>     static hasMany = [authors:Author]
>     static mappedBy = [authors:"books"]
>
>     String title
> }
> =========================================
>
> All is ok like this.
>
> Now if I try to add a field with the type Book in class Author :
>
> 1. if the field name start with book... like in
>
> =========================================
> class Author {
>     static hasMany = [books:Book]
>     static mappedBy = [books:"authors"]
>
>     String name
>     Book bookOther
> }
> =========================================
>
> , it fails immediately with the exception :
>
> 2007-10-09 14:51:34.141::WARN:  Nested in
> 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 fa
> iled; nested exception is java.lang.NullPointerException:
> java.lang.NullPointerException
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.linkBidirectionalOneToMany(GrailsDomainBinder.java:420)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.bindCollectionSecondPass(GrailsDomainBinder.java:296)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.access$100(GrailsDomainBinder.java:52)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder$GrailsCollectionSecondPass.doSecondPass(GrailsDomainBinder.java:156)
>         at
> org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
>         at
> org.codehaus.groovy.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.secondPassCompile(DefaultGrailsDomainConfiguration.java:95)
>         at
> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
>         at
> org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:804)
>         at
> org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.newSessionFactory(ConfigurableLocalSessionFactoryBean.java:87)
>         at
> org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:744)
>         at
> org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
>         at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:245)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:124)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1019)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
>         at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
>         at
> org.codehaus.groovy.grails.orm.support.TransactionManagerPostProcessor.postProcessBeanFactory(TransactionManagerPostProcessor.java:42)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:314)
>         at
> org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:90)
>         at
> org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:261)
>         at
> org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:232)
>         at
> org.codehaus.groovy.grails.commons.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:103)
>         at
> org.codehaus.groovy.grails.web.context.GrailsContextLoader.createWebApplicationContext(GrailsContextLoader.java:35)
>         at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
>         at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
>         at
> org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:530)
>         at org.mortbay.jetty.servlet.Context.startContext(Context.java:135)
>         at
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
>         at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
>
> 2. if the field name don't start with book, it is ok.
>
> Even more strange, in our real project, with any name, it fails...
>
> It seems to be a bug. Could you confirm this ?
> Do I have to add it to JIRA ?
>
> Thanks,
>
> Olivier
>
> PS: We are using grails version 0.6 on Windows XP.
> --
> View this message in context: http://www.nabble.com/Many-to-many-bug---tf4594097.html#a13115160
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Graeme Rocher
Grails Project Lead
http://grails.org

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email