ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James, Steven" <Steven.Ja...@logicacmg.com>
Subject RE: null value from db query caused ibatis setProperty error
Date Wed, 13 Jul 2005 06:51:10 GMT
You cant set a primative to null.. You can define a null default like this in your parameter
map
<result property="description" column="DESCRIPTION" nullValue=""/>

steve


-----Original Message-----
From: Stan Ou [mailto:jou128@yahoo.com]
Sent: Tue 7/12/2005 4:24 PM
To: user-java@ibatis.apache.org
Subject:  null value from db query caused ibatis setProperty error
 
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 



This e-mail and any attachment is for authorised use by the intended recipient(s) only. It
may contain proprietary material, confidential information and/or be subject to legal privilege.
It should not be copied, disclosed to, retained or used by, any other party. If you are not
an intended recipient then please promptly delete this e-mail and any attachment and all copies
and inform the sender. Thank you.

Mime
View raw message