Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null value to an integer attribute

 
Danilo Dadonas
Ranch Hand
Posts: 59
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, there is an integer attribute in my class referencing an NUMBER field of the database. When this field is null, I get this exception:

org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of ...

I know that I'm getting this exception because hibernate is trying to assign a null value to an integer and it's not possible.
How can I map with annotations this attribute in my class?

This is that I'm using now:



Thanks in advance.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change it to use an Integer rather than a primitive type.
 
Danilo Dadonas
Ranch Hand
Posts: 59
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul, I changed the code to



and it's working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic