Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 0.4
-
Fix Version/s: 1.3-RC1
-
Component/s: Persistence
-
Labels:None
Description
Declaring a property as an int, with nullable: true and listing it in optionals, you get the following error when trying to load an object that has a null value in that column:
Grails Runtime Exception Error Details Message: Null value was assigned to a property of primitive type setter of Recipe.servesHowMany; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of Recipe.servesHowMany Caused by: org.springframework.orm.hibernate3.HibernateSystemException: Null value was assigned to a property of primitive type setter of Recipe.servesHowMany; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of Recipe.servesHowMany Class: RecipesController At Line: [17] Code Snippet: 17: return fetchRecipeModel(Recipe.CATEGORY_DISH) 18: } Stack Trace org.codehaus.groovy.runtime.InvokerInvocationException: org.springframework.orm.hibernate3.HibernateSystemException: Null value was assigned to a property of primitive type setter of Recipe.servesHowMany; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of Recipe.servesHowMany at org.codehaus.groovy.runtime.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:75) at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:713) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:559) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:449) at groovy.lang.Closure.call(Closure.java:188) at groovy.lang.Closure.call(Closure.java:183) at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleAction(SimpleGrailsControllerHelper.java:369) at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:280) at .... 81 more Caused by: java.lang.IllegalArgumentException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 96 more
This one is not fixable, in fact it is not even isolated to Grails as you can reproduce this problem by using int values that have nullable columns with Hibernate. It will throw the same exception