-->
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.  [ 5 posts ] 
Author Message
 Post subject: Handling null in queries
PostPosted: Thu Nov 11, 2010 6:35 am 
Newbie

Joined: Thu Nov 11, 2010 6:27 am
Posts: 4
hi,
I am fairly new to Java and hibernate so please bare with me if this is a fairly simple question.

This is my scenario:

select id,name from table

Now i want to handle null in name.

One way of handling null would be to check in the Hibernate generated class, but currently my project doesn't allow me to handle this. So I would have to write another model class which will have all the getter/setter methods and handle this values. But somewhere deep inside I think this is not the right way to go about.

So I would have to handle null in query itself.

Also efficient wise which one would be more efficient:
1. Handling nulls in the query
2. Handling nulls in the code.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Handling null in queries
PostPosted: Thu Nov 11, 2010 7:30 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
You do not need to "handle" null. These values are totally fine.


Top
 Profile  
 
 Post subject: Re: Handling null in queries
PostPosted: Thu Nov 11, 2010 8:05 am 
Newbie

Joined: Thu Nov 11, 2010 6:27 am
Posts: 4
Hi,
Thanks for the reply...
r wrote:
You do not need to "handle" null. These values are totally fine.

But if null value is returned from the query I want to set some default value for that cell...


Top
 Profile  
 
 Post subject: Re: Handling null in queries
PostPosted: Thu Nov 11, 2010 9:37 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Eldersscroll wrote:
But if null value is returned from the query I want to set some default value for that cell...


Why?!


Top
 Profile  
 
 Post subject: Re: Handling null in queries
PostPosted: Thu Nov 11, 2010 9:53 am 
Newbie

Joined: Thu Nov 11, 2010 6:27 am
Posts: 4
Hi,
The business logic forces me not to use null value.
Any ways I found the solution. Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.