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

后端 未结 12 888
长情又很酷
长情又很酷 2021-01-30 07:58

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         


        
12条回答
  •  感动是毒
    2021-01-30 08:43

    A primitive type cannot be null. So the solution is replace primitive type with primitive wrapper class in your tableName.java file. Such as:

    @Column(nullable=true, name="client_os_id")
    private Integer client_os_id;
    
    public int getClient_os_id() {
        return client_os_id;
    }
    
    public void setClient_os_id(int clientOsId) {
        client_os_id = clientOsId;
    }
    

    reference http://en.wikipedia.org/wiki/Primitive_wrapper_class to find wrapper class of a primivite type.

提交回复
热议问题