Why do I get a "Null value was assigned to a property of primitive type setter of" error message when using HibernateCriteriaBuilder in Grails

Peter picture Peter · Jul 1, 2010 · Viewed 128.3k times · Source

I get the following error when using a primitive attribute in my grails domain object:

Null value was assigned to a property of primitive type setter of MyDomain.myAttribute
 org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of MyDomain.myAttribute
at grails.orm.HibernateCriteriaBuilder.invokeMethod(HibernateCriteriaBuilder.java:1077)

Answer

Peter picture Peter · Jul 1, 2010

According to this SO thread, the solution is to use the non-primitive wrapper types; e.g., Integer instead of int.