-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Null value was assigned to a property of primitive type
PostPosted: Mon Nov 22, 2010 10:12 am 
Newbie

Joined: Thu Nov 18, 2010 6:39 am
Posts: 1
Hi Friends,

I found this content important for all hibernate users and found interesting to post here.

In my project I got the issue when I was trying to fetch records using from object ... query.
The exception was org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of

and the reason is a small silly mistake as:
it was fetching one data as 'null' and the field was declared as primitive type in POJO class of hibernate. And in the hbm the type is not given. Example,

in hbm.xml,
<property name="age" column="emp_age"/>

class Employee{
int age; //here is the error with datatype
}

and the reason is a premitive type can't have null value.
So always set the value as abstract type i.e. the correct one is:

Integer age;


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.