commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amir Nashat" <anas...@cj.com>
Subject BeanUtils SqlConversion
Date Wed, 03 Mar 2004 00:23:30 GMT
Hello All,

 

I've been having a small problem with the BeanUtils utility. I'm
attempting to perform a copy of a java.sql.Date field, which can be
null, to a bean. The problem I am getting is that when the field is null
I get a ConverstionException. After inspecting the code I found that the
SqlConverter class is called and the convert() checks the following :

 

if (value == null) {

            if (useDefault) {

                return (defaultValue);

            } else {

                throw new ConversionException("No value specified");

            }

        }

 

I am wondering why the conversion exception is thrown in the first
place. Couldn't the check for null return the default value else no
value at all and skip that attribute? Also, for anyone out there that
has to perform type conversion and copy properties (of which some date
attributes can be null) to a bean what is your implementation? How are
you avoiding my problem?

 

Thank you for your help.

 

Amir

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message