Thread:
 Error in default values implementation 
 MattFlower   06 Aug 2006, 01:43 
 Re: Error in default values implementation 
 levmatta   04 Sep 2006, 14:11 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: levmatta (04 Sep 2006, 14:11) Replies: 0, Views: 26025
Subject: Re: Error in default values implementation
On 06 Aug 2006 01:43, MattFlower wrote:

>This is a nice, simple implementation, but I think there is at least
>one error in the implementation of default values.

Thanks for the comments (to sebastian.fiorentini too), this code has
been very useful to me and I was already thinking that it was to me
alone. About the error comment:

>As is, nullSafeGet won't use the default value because of the check on
>rs.wasNull(). If we intend to use the default value there, I believe
>that (name == null) would be a better check..

I disagree, please forgive me if I did not understand your point. The
default value is returned when the field is NULL, so that if the
value is set there is no excuse to not finding the name (actually
throwing an exception).

>Another decent question would be whether nullSafeSet should be
>explicitly setting the default value or the null value.  If it should
>be setting the default value, there is no handling of such.

I can justify not to set the default value when it is
NULL, but these are ultimately thin and better advice would be to do
what your business needs:
- fewer changes to the database
- not messing with values that can have other meanings

In particular this last one means that the one application will be well
behaved considering other ones and considering evolutions. If someone
update the field meaning, allowing other values, you will fail and will
NOT change the database.


Finally, to me "defaultValue" if more a help to applications, so they do
not have to deal with null. Simply, it makes creating screens (html
pages) easier.

Chears to all.
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]