ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Boyd" <swb...@gmail.com>
Subject Re: how to create custom TypeHandlerCallback to trim string whitespace
Date Fri, 18 Jan 2008 21:53:24 GMT
Can you use a db function to trim the value before it reaches ibatis?  I am
not familiar with informix, but in db2 I use the rtrim() function.  I am
sure there must be something similar.



On Jan 18, 2008 2:01 PM, novotny <novotny@gridsphere.org> wrote:

>
> Hi,
>
>  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 database
> and normally when I get them back they contain extar whitespace. I'm
> trying
> to create a custom handler like so:
>
> public class StringTypeHandlerCallback implements TypeHandlerCallback {
>
>
>    public void setParameter(ParameterSetter parameterSetter, Object o)
> throws SQLException {
>        parameterSetter.setString(((String)o).trim());
>    }
>
>    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"
> jdbcType="CHAR"/>
>
> 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,
> "sm_qwest",
> "tm_id");
>
> Any help is greatly appreciated!
>
> Thanks, Jason
> --
> View this message in context:
> http://www.nabble.com/how-to-create-custom-TypeHandlerCallback-to-trim-string-whitespace-tp14956784p14956784.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Mime
View raw message