-->
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: Getting Null from database with hibernate
PostPosted: Tue Jan 02, 2007 2:41 pm 
Newbie

Joined: Fri Dec 15, 2006 5:49 pm
Posts: 16
I have this comment field in the database and if it is empty in the database I get the value "null" in my commnets fields which i dont want... we tried checking for nulls in the jsp but it doesnt work... and the null value still appears on the jsp.... how do i fix this


Top
 Profile  
 
 Post subject: Re: Getting Null from database with hibernate
PostPosted: Tue Jan 02, 2007 5:23 pm 
Newbie

Joined: Wed Aug 03, 2005 2:13 am
Posts: 16
Hi SuperMan,

This isn't really a Hibernate question, it's related to how you are getting the property from your object into your JSP.

It's probably due to the fact that the String.valueOf() method returns "null" if the object is null:

Code:
    public static String valueOf(Object obj) {
   return (obj == null) ? "null" : obj.toString();
    }


You can change the getter method of your object so that it returns empty string if the value is null, instead of returning null and making the JSP renderer convert it to a string.

hope that helps,
D.

SuperMan2000 wrote:
I have this comment field in the database and if it is empty in the database I get the value "null" in my commnets fields which i dont want... we tried checking for nulls in the jsp but it doesnt work... and the null value still appears on the jsp.... how do i fix this


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.