From: Anton v. S. <an...@ap...> - 2002-05-25 21:46:48
|
I ran into a problem where a NullPointerException was being thrown from deep inside Hibernate (latest version), with no real clue as to what the problem was: java.lang.NullPointerException at java.lang.reflect.Method.invoke(Native Method) at cirrus.hibernate.impl.ClassPersister.setPropertyValues(ClassPersister.java:4 49) at cirrus.hibernate.impl.ClassPersister.hydrate(ClassPersister.java:680) at cirrus.hibernate.impl.RelationalDatabaseSession.loadFromResultSet(Relational DatabaseSession.java:1133) ... It took me a while to figure out where to look. It turned out that there was a null value in my database, in a column with a setter method that expects a Java double - so really, the problem was either with my data or with the setter method, depending on how you look at it. To make the error message more helpful in future, I've added an exception case to ClassPersister.setPropertyValues: catch (NullPointerException npe) { throw new HibernateException( "NullPointerException occurred inside setter for class " + className + ", property " + propertyNames[j] ); } I've checked the change into CVS - if there's a better way to handle this, please let me know. Anton |