I have an existing application with 10 or so hibernate beans with composite id's. This prevents the application from starting up.
This issue is somewhat related to issue GRAILS-241, where a NullPointerException was fixed.
The following code in the constructor of GrailsHibernateDomainClass could still result in a NPE because propertyMap.put is called with 2 nulls as argument.
if (ident != null) {
Class identType = bean.getPropertyType(ident);
this.identifier = new GrailsHibernateDomainClassProperty(this, ident);
this.identifier.setIdentity(true);
this.identifier.setType(identType);
}
propertyMap.put(ident, identifier);
The TreeMap will then generate a NullPointerException during one of the next puts:
Caused by: java.lang.NullPointerException
at java.lang.String.compareTo(String.java:1168)
at java.lang.String.compareTo(String.java:92)
at java.util.TreeMap.put(TreeMap.java:545)
at org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateDomainClass.<init>(GrailsHibernateDomainClass.java:136)
at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.configureDomainClass(GrailsHibernateUtil.java:132)
at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.configureHibernateDomainClasses(GrailsHibernateUtil.java:98)
at org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.newSessionFactory(ConfigurableLocalSessionFactoryBean.java:88)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:667)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1303)
... 274 more
This can be easily fixed by putting the propertyMap.put inside the if too. (patch included)
Don't know if this solves everything but at least the application will start up.
Description
I have an existing application with 10 or so hibernate beans with composite id's. This prevents the application from starting up.
This issue is somewhat related to issue GRAILS-241, where a NullPointerException was fixed.
The following code in the constructor of GrailsHibernateDomainClass could still result in a NPE because propertyMap.put is called with 2 nulls as argument.
if (ident != null) {
Class identType = bean.getPropertyType(ident);
this.identifier = new GrailsHibernateDomainClassProperty(this, ident);
this.identifier.setIdentity(true);
this.identifier.setType(identType);
}
propertyMap.put(ident, identifier);
The TreeMap will then generate a NullPointerException during one of the next puts:
Caused by: java.lang.NullPointerException
at java.lang.String.compareTo(String.java:1168)
at java.lang.String.compareTo(String.java:92)
at java.util.TreeMap.put(TreeMap.java:545)
at org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateDomainClass.<init>(GrailsHibernateDomainClass.java:136)
at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.configureDomainClass(GrailsHibernateUtil.java:132)
at org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil.configureHibernateDomainClasses(GrailsHibernateUtil.java:98)
at org.codehaus.groovy.grails.orm.hibernate.ConfigurableLocalSessionFactoryBean.newSessionFactory(ConfigurableLocalSessionFactoryBean.java:88)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:667)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1303)
... 274 more
This can be easily fixed by putting the propertyMap.put inside the if too. (patch included)
Don't know if this solves everything but at least the application will start up.