History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GRAILS-1868
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: Graeme Rocher
Reporter: René de Bloois
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Grails

NullPointerException during 'grails run-app', with composite-id domain classes

Created: 22/Nov/07 09:04 AM   Updated: 23/Nov/07 07:43 AM
Component/s: Persistence
Affects Version/s: 1.0-RC1
Fix Version/s: 1.0-RC2

Time Tracking:
Not Specified

File Attachments: 1. Text File GrailsHibernateDomainClass.patch (0.8 kb)


Patch Submitted: Yes


 Description  « Hide
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.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Graeme Rocher - 23/Nov/07 07:43 AM
fixed. thanks