ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: I have a TypeHandler that converts Y/N to boolean, but sometimes Y/N might be null...
Date Thu, 18 May 2006 06:55:52 GMT
I think your typehandler.valueOf() implementation is incorrect. The
string passed to it is the string you specified in the attribute
"nullValue". You should do something like:

public Object valueOf(String s) {
  return "Y".equals(s);
}

Niels

-----Original Message-----
From: Rick Reumann [mailto:rickcr@gmail.com] 
Sent: donderdag 18 mei 2006 2:34
To: user-java@ibatis.apache.org
Subject: I have a TypeHandler that converts Y/N to boolean, but
sometimes Y/N might be null...

My boolean TypeHander for columns in the database that are Y or N is
working great (thanks Nathan). The problem now, however, is that I
have an outer join that joins on that table with the Y/N varchar
column will sometimes be null.

I'm using the type handler globally (defined in sqlMap config). The
problem is on these null columns I want the boolean value to be "true"
but I'm having difficulty setting it up. I've tried various settings
for the nullValue on the resultMap for these boolean fields, but I
still end up getting an error like:

--- The error occurred while applying a result map.
--- Check the Subscriptions.subscriptionsMap.
--- The error happened while setting a property on the result object.
--- Cause: com.ibatis.common.beans.ProbeException: Could not set
property 'subscribedToEmail' for com.nielsenmedia.npn.v
o.Subscription.  Cause: java.lang.IllegalArgumentException: argument
type mismatch
Caused by: java.lang.IllegalArgumentException: argument type mismatch
Caused by: com.ibatis.common.beans.ProbeException: Could not set
property 'subscribedToEmail' for com.npn.v
o.Subscription.  Cause: java.lang.IllegalArgumentException: argument
type mismatch
Caused by: java.lang.IllegalArgumentException: argument type mismatch


I've tried

 <result property="displayOnline"
column="displayOnlineFlag"  javaType="boolean" nullValue="true"/>

and also tried nullValue="Y"  and tried adding jdbcType="VARCHAR"

Any ideas what I need to do to get the null value working with my
handler (other than altering the handler's code)?

-- 
Rick

Mime
View raw message