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: best practice with NULL question
PostPosted: Wed Sep 21, 2005 4:37 pm 
Newbie

Joined: Fri Apr 01, 2005 8:45 pm
Posts: 17
Hello,

I'm in the middle of a hibernate project and I wanted some opinions from the group as to the best way to handle an issue with NULL values.

We have a table with 10 varchar columns and one of the columns can sometimes have a NULL value. Is it better to actually use a NULL value or instead use some agreed to string value that will mean null? For example the empty string, or "*" or "NULL" or any string that won't conflict with real data. Obviously from the DBA's point of view we should use an actual NULL value. Saves space, and is a more correct representation of the data.

But, from my Java program with Hibernate's perspective I have to do a lot of extra work for the null case. If I could just use the empty string to represent null I could leave the code as is... so is it worth the extra work? What does it really buy me?

Thanks,
-Andrew
http://www.engineering-utopia.com/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 3:12 am 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
I can hardly imagine that using some default value instead of null will save you that much extra work because you'll have to make a distinction between that default value and a real value anyway.

The main difference will probably be that, when you forget to handle the special cases in a special way, using null will lead to a NPE, while you first won't notice with the default value - but you'll have to do some clean up afterwards. You therefore exchange handling of null for subtle bugs...

In any case I really don't think that your issues of handling null should be of any interest to the database. Have it Nullable in the database and let the objects take care of anything else.

My humble opinion on this subject :-)

Erik


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.