-->
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.  [ 2 posts ] 
Author Message
 Post subject: PropertyAccessException: Null value was assigned to a proper
PostPosted: Tue Feb 23, 2010 4:46 am 
Newbie

Joined: Tue Jun 21, 2005 4:53 am
Posts: 2
Hi

My persisted entity has a primitive "selected" boolean field that does not require persistence. When the entity is loaded, however, the PropertyAccessException is thrown, as the setter for selected requires a non-null, non-primitive value. Without declaring the field as a column, I cannot tell hibernate to set the field to not-nullable.

Quote:
org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.geca.domain.ContactPerson.selected
...
Caused by: java.lang.IllegalArgumentException: Can not set boolean field com.geca.domain.ContactPerson.selected to null value


All answers on the web tell me to change the primitive to it's wrapper type, but I'd like to avoid this as it forces me to put in unnessecarry null-checks in controller logic.

Is there a way I can retain the primitive type on this entity?

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: PropertyAccessException: Null value was assigned to a proper
PostPosted: Tue Feb 23, 2010 4:08 pm 
Beginner
Beginner

Joined: Tue Aug 25, 2009 11:42 am
Posts: 49
If it DOES NOT require to be persisted why are u mapping it? If u are using xml-mapping:
<class name="Person">
<property name="selected"/>
...
</class>

remove the <property name="selected"/> line altogether, Hibernate doesn't need to know about it.
And if u are using annotations,
@Transient
boolean selected;


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

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.