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
<result property="description" column="DESCRIPTION" nullValue=""/>


-----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
and the corresponding db column returns null from the

This acutally caused ibatis to throw an error in
com.ibatis.common.beans.ComplexBeanProbe.java on
  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
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.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

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.

View raw message