commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <robertburrelldon...@blueyonder.co.uk>
Subject Re: BeanUtils SqlConversion
Date Sun, 07 Mar 2004 21:50:59 GMT
hi

i think that the idea is that if you don't want a conversion exception 
to be thrown, you should specify a default.

- robert

On 3 Mar 2004, at 00:23, Amir Nashat wrote:

> 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
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message