Hi There, we got a strange scenario in our Hibernate based web application.
On the Database SQL Server 2005,there is a field called user_type of Boolean type and it will store True or False messages and this Data Base SQL Server2005 allows to store "NULL" into this field which is very strange. When run a HQL Query and set these values into Bean Hibernate will through exceptions saying
I am not sure how to handle this scenario. In the first case how come DB SQL Server2005 is allowing to store "NULL" values into Primitive types and Hibernate/Java or any programming language cannot/impossible to store NULL into primitive data types. Any arguments/answers please. Thanks in advance,VijayGadde
Coming together is a beginning. Keeping together is progress.. Working together is success........
On the Database SQL Server 2005,there is a field called user_type of Boolean type and it will store True or False messages and this Data Base SQL Server2005 allows to store "NULL" into this field which is very strange.
Why is that strange? Presumably if you want to use a boolean type with a nullable field then the value can be null?
As a general rule, if you have mapped a primitive type to any field that is nullable your mapping is wrong. [ October 15, 2008: Message edited by: Paul Sturrock ]
Now I had Fixed this NULL issues in my application.
If one declares these int,bit,char as Primitive data types in POJO classes.. then we cannot do getter/setter NULL value into this attributes.. but on you these values will allow NULL to store.. so to avoid this conflicts its always suggestible to use WRAPPER classes itself not Primitive types.
What I had observed.. On the DB we have inter, bit types.
How do we need declare them in our Hibernate POJO classes
> Point1: We would need to initialize these variable with WRAPPER classes only like int - "Integer" bit - "Boolean" char - "Character"
does any one dis-agree with this, any comments/suggestions please..!
I am getting same problem .
FATAL [reviewBoard] Error in getReviewBoardDetails() in ReviewBoardAgentBeanjavax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.velos.eres.business.reviewboard.impl.ReviewBoardBean.reviewboardAccId
In this case, i am trying to get name of all Review Board Names.When i click on records inserted by form , i am able to get those records Name , but when i am trying to get records that were inserted in table as seed data.I am getting this error?
I am using "int" in my "ReviewBoardJB.java" file. I am not getting if this is error due to primitive data-type, then why it work with others that records inserted by form.
Please guide me how to solve this.
Seems there is null values when you retireve from the table and hence the error, whereas when you enter from the form you enter values for all the fields. Use wrappers for all primitives in your class.
subject: Handling Null values in Java Primitive DATA types