ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kezerashvili, Denis" <Denis.Kezerashv...@gs.com>
Subject RE: how to create custom TypeHandlerCallback to trim string whitespace
Date Fri, 18 Jan 2008 21:01:45 GMT
One more point, you need the following in your sql mapping xml file, in
you result map, for the column you want to trim:

<result property="[propertyToSet]" column="[columnNameToUse]"
javaType="StringTypeHandlerCallback" jdbcType="VARCHAR"/>

Replace things in [] with correct values for your use.

Make sure the StringTypeHandlerCallback is either fully qualified name
of defined in the typeAlias.


-----Original Message-----
From: novotny [mailto:novotny@gridsphere.org] 
Sent: Friday, January 18, 2008 2:02 PM
To: user-java@ibatis.apache.org
Subject: how to create custom TypeHandlerCallback to trim string


 I'm using an informix database and querying for a map containing string
keys and integer values. The keys are stored as type CHAR in the
and normally when I get them back they contain extar whitespace. I'm
to create a custom handler like so:

public class StringTypeHandlerCallback implements TypeHandlerCallback {

    public void setParameter(ParameterSetter parameterSetter, Object o)
throws SQLException {

    public Object getResult(ResultGetter resultGetter) throws
SQLException {
        return resultGetter.getString().trim();

    public Object valueOf(String s) {
        return s.trim();

and I added 

<typeHandler callback="StringTypeHandlerCallback" javaType="string"

but it doesn't seem to work-- the strings still have the whitespace.

Here was my query:

Map<String, Integer> m = sqlMapClient.queryForMap(QUERY, qwest,

Any help is greatly appreciated!

Thanks, Jason
View this message in context:
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

View raw message