-->
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: Mapping a Table to Entity Class Doubt
PostPosted: Fri Jan 06, 2012 3:48 am 
Newbie

Joined: Tue Dec 06, 2011 3:00 am
Posts: 1
Hi Everyone I am newbie to hibernate i have small doubt

For Example ,

I have Entity Employee..
@Entity
@Table(name="Employee")
Employee(){
@id
@Column(name="employeeID",unique=true, nullable=false)
int id;
@Column(name="employeeName",unique=false, nullable=true)
String Name;
@Column(name="employeeAge",unique=false, nullable=true)
int age;
...
....
}

consider everything configured properely for entity

when i am fetching Employee object from table if age value is null;

In Employee entity (int age) is an primitive type. how it will map ....


Top
 Profile  
 
 Post subject: Re: Mapping a Table to Entity Class Doubt
PostPosted: Mon Jan 09, 2012 9:37 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
You will get a NullPointerException if the value in the database is null. To fix it, you'll need to make sure all values are non-null or use an Integer instead of an int in your code.


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.