java 7 - net.sf.hibernate.PropertyValueException: not-null property references a null or transient value -
I am trying to set the 'level' with some values but I get an exception. Below is the version and code.
Hibernate Version: 2.1
Server: Weblogic 11g
Mapping Document:
& lt; Property name = "level" type = "java.lang.Integer" & gt; & Lt; Meta attribute = "default-value" & gt; New java.lang.Integer (0) & lt; / Meta & gt; & Lt; Column name = "level" no-null = "true" length = "3" /> & Lt; / Property & gt;
Code:
Public poll filled (throws as a result) throws SQLException {POL p = new pol (); P.setLevel (new integer (rs.getInt ("setLevel")); If (rs.IsNull ()) {p.SetLevel (null); } Return p; }
Exception I get
by: net.sf.hibernate.PropertyValueException: Not-null property references a blank or transient value
Please help.
That's because you have DB < -> Java DataTip Mismatch
To fix this check:
- DB column if it is allowed for zero values
- Java type if it is the initial type or not .
Try the following:
Public poll filled (throws as a result) throws SQLException {POL p = new pol (); P.setLevel (new integer (rs.getInt ("setLevel")); If (rs.IsNull ()) {p.setLevel (Integer.valueOf (0)); // According to the mapping you are not emptying it, but return zero; }
Comments
Post a Comment