Error added: 2008-02-26T14:16:17Z
I have the same problem. The problems was that the value in the database was NULL so when Hibernate try to set the value NULL from the DB to the set method which accept a primitive value it throw an error. Solution: Change the set to Integer or set the value in the DB to be No Null and set some default value.
Set the field to be java.lang.Integer rather than int
Answer 1 worked for me. Example segment from mapping *hbm.xml file: ... <property name=\"myVar\" type=\"int\"> <column name=\"MYCOLUMN\" not-null=\"false\"/> </property> ------ Relevant variable definition in mapping class. Integer myvar; public Integer getMyvar() { return myvar; } public void setMyvar(Integer myvar) { this.myvar = myvar; }
Answer 8 worked for me for MS SQL. \"If your object has a primitive-type property mapped to a nullable database column then you will need to use a Hibernate custom type to assign a sensible default (primitive) value for the case of a null column value. A better solution is usually to use a wrapper type for the Java property.\"
Answer 1 worked for me when i used Double at the place of double and Character at the place of char. If ur value is become nullable then dont use primtive type. If your object has a primitive-type property mapped to a nullable database column then you will need to use a Hibernate custom type to assign a sensible default (primitive) value for the case of a null column value. A better solution is usually to use a wrapper type for the Java property.
Answer2 worked for me too. Thank u
Answer 2 is the perfect solution to the problem
ans 2 is right when i am using Oracle 10g with Hibernate 3.0
use formula=\"ifnull(columnname,0)\" for int/long datatype in the property element
Answer 1 worked for me when i used Double at the place of double and Character at the place of char. If ur value is become nullable then dont use primtive type. If your object has a primitive-type property mapped to a nullable database column then you will need to use a Hibernate custom type to assign a sensible default (primitive) value for the case of a null column value. A better solution is usually to use a wrapper type for the Java property.
If you know the answer, please add your own solution below.
If you don't know, but find out later, please come back and share your answer - there will be other people
struggling with this too.
If you want to be notified via email when this is solved, enter your email address here: