This is not really related to iBATIS, but just a simple fact of Java -
it is not possible to represent null values in a primitive variable
unless you want to use a magic number (i.e., assume that -1 or 0.123
is null - which IMO is a very, very bad idea).
If you need null, use Float, not float.
Larry
On 7/12/05, Stan Ou <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a simple query and its result is mapped to a
> Java value object (vo), pretty straight forward stuff.
> My problem is that one of my properties in my vo is a
> float type (or any primitive numeric type for that
> matter)
> and the corresponding db column returns null from the
> query.
>
> This acutally caused ibatis to throw an error in
> com.ibatis.common.beans.ComplexBeanProbe.java on
> setProperty()
> {
> method.invoke(object, params);
> }
>
> Here it's trying call method setBlaBlah(float f) via
> reflection and passing params (params is null, in this
> case.) Since setBlaBlah() takes in a primitive float
> type, passing a null causes it to throw an error. My
> question
> is has anyone run into this problem and how did you
> fix it?
>
> My temp work around is to modify that class by first
> checking if params is null. If it's null, don't set
> the property. But this created another undesired
> side-effect. when my vo is instantiated, the float
> property is initialized to 0.0, which is how Java does
> things, since setBlaBlah(float f) never got called ,
> now that property shows up as 0.0 instead of nothing.
>
> Any comments/suggestions are greatly appreciatged.
> Thanks.
>
> stan
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>