Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 88054 invoked from network); 22 Jan 2008 22:24:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jan 2008 22:24:33 -0000 Received: (qmail 36828 invoked by uid 500); 22 Jan 2008 22:24:17 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 36815 invoked by uid 500); 22 Jan 2008 22:24:17 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 36804 invoked by uid 99); 22 Jan 2008 22:24:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jan 2008 14:24:17 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of swboyd@gmail.com designates 72.14.220.157 as permitted sender) Received: from [72.14.220.157] (HELO fg-out-1718.google.com) (72.14.220.157) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jan 2008 22:23:50 +0000 Received: by fg-out-1718.google.com with SMTP id d23so2057580fga.32 for ; Tue, 22 Jan 2008 14:23:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=AAyXbqd4Gopn5UK8Vf4aMHuTM7oUY6lU/BLH44REyXg=; b=hOPoUlfIrwxEWEqCCf77ahDDift4QK1UDOKO5eDOcJEiiUmCSbSf7ZRcZBCsOv39FnbWw/+OpgAcKWStS5VZFA0MPfxnvNgzrSxlBfE5memO2QC839QtK+ILFCs0zejfL8A7X3cnZUPPnj+8XMPotAzSpbLwmffPggBaZy8M6a8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=L/RwX6gc2f7eLd4lAw+8RtWkzGO6drdhTeubLd6ubs9ebmRPeSdARH/N9KBUacrGdn/eFeNwwvoLmxdbQMgn251HvHgHHaaSAe4TUze5vi87rrXi/h5+ruOETspBtTPO/pqOz4UyN1g4+Tw/FnUFPg047M2Vh9e16pAxg1LXUNM= Received: by 10.86.80.5 with SMTP id d5mr8203568fgb.20.1201040635589; Tue, 22 Jan 2008 14:23:55 -0800 (PST) Received: by 10.86.63.20 with HTTP; Tue, 22 Jan 2008 14:23:55 -0800 (PST) Message-ID: <80bfbb6d0801221423s10acd151q5123e73c5c8239a3@mail.gmail.com> Date: Tue, 22 Jan 2008 17:23:55 -0500 From: "Stephen Boyd" To: user-java@ibatis.apache.org Subject: Re: how to create custom TypeHandlerCallback to trim string whitespace In-Reply-To: <15029467.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16442_30100543.1201040635569" References: <14956784.post@talk.nabble.com> <9A1FB294C6BAB244BF5EC1A90DD580703E25E5@gsmbcdp25es.firmwide.corp.gs.com> <15028271.post@talk.nabble.com> <80bfbb6d0801221340n189720e1xdae08405a40a64a5@mail.gmail.com> <15029467.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_16442_30100543.1201040635569 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hmm.... Did you try TRIM(trailing ' ' from sm_issue_symbol)? On Jan 22, 2008 4:59 PM, novotny wrote: > > > Hi, > > That's what I wanted to but for whatever reason maybe because it's CHAR or > maybe because it's informix, but it doesn't trim the string so I still get > whitespace padding... :-( > > Jason > > > > Stephen Boyd-3 wrote: > > > > Why don't you change your select clause to this? > > > > select *trim(sm_issue_symbol) as sm_issue_symbol*, > > tm_id > > from > > sec_master, > > category_security, > > tier_mast > > where sm_secid = cs_secid > > and cs_tierid = tm_id > > and sm_issue_symbol is not NULL > > and sm_issue_symbol != " " > > order by 1, 2; > > > > On Jan 22, 2008 3:59 PM, novotny wrote: > > > >> > >> Hi, > >> > >> I'm not quite sure what you mean-- this is what I have in my > >> sql-ibatis.xml > >> file: > >> > >> > >> > >> So my resultMap is just a generic HashMap where the keys consist of the > >> sm_issue_symbol that I want trimmed and the values are the integers > from > >> the > >> tm_id column. > >> What would the property attribute in the result element need to be set > >> to? > >> > >> Thanks, Jason > >> > >> > >> > >> Kezerashvili, Denis wrote: > >> > > >> > One more point, you need the following in your sql mapping xml file, > in > >> > you result map, for the column you want to trim: > >> > > >> > > >> > >> > 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. > >> > > >> > Denis > >> > > >> > -----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 > >> > whitespace > >> > > >> > > >> > 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 > >> > > >> > >> > jdbcType="CHAR"/> > >> > > >> > but it doesn't seem to work-- the strings still have the whitespace. > >> > > >> > Here was my query: > >> > > >> > Map 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-s > >> > tring-whitespace-tp14956784p14956784.html > >> > Sent from the iBATIS - User - Java mailing list archive at Nabble.com > . > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://www.nabble.com/how-to-create-custom-TypeHandlerCallback-to-trim-string-whitespace-tp14956784p15028271.html > >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/how-to-create-custom-TypeHandlerCallback-to-trim-string-whitespace-tp14956784p15029467.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > > ------=_Part_16442_30100543.1201040635569 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hmm....  Did you try TRIM(trailing ' ' from sm_issue_symbol)? 

On Jan 22, 2008 4:59 PM, novotny <novotny@gridsphere.org> wrote:


Hi,

That's what I wanted to but for whatever reason maybe because it's CHAR or
maybe because it's informix, but it doesn't trim the string so I still get
whitespace padding... :-(

Jason



Stephen Boyd-3 wrote:
>
> Why don't you change your select clause to this?
>
>    select *trim(sm_issue_symbol) as sm_issue_symbol*,
>           tm_id
>    from
>            sec_master,
>            category_security,
>            tier_mast
>        where sm_secid = cs_secid
>            and cs_tierid = tm_id
>            and sm_issue_symbol is not NULL
>            and sm_issue_symbol != " "
>        order by 1, 2;
>
> On Jan 22, 2008 3:59 PM, novotny < novotny@gridsphere.org> wrote:
>
>>
>> Hi,
>>
>> I'm not quite sure what you mean-- this is what I have in my
>> sql-ibatis.xml
>> file:
>>
>> <select id="GetAllSecTiers" resultClass="java.util.HashMap">
>>        select
>>            sm_issue_symbol,
>>            tm_id
>>        from
>>            sec_master,
>>            category_security,
>>            tier_mast
>>        where sm_secid = cs_secid
>>            and cs_tierid = tm_id
>>            and sm_issue_symbol is not NULL
>>            and sm_issue_symbol != " "
>>        order by 1, 2;
>>    </select>
>>
>> So my resultMap is just a generic HashMap where the keys consist of the
>> sm_issue_symbol that I want trimmed and the values are the integers from
>> the
>> tm_id column.
>> What would the property attribute in the result element need to be set
>> to?
>>
>> Thanks, Jason
>>
>>
>>
>> Kezerashvili, Denis wrote:
>> >
>> > 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.
>> >
>> > Denis
>> >
>> > -----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
>> > whitespace
>> >
>> >
>> > 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-s
>> > tring-whitespace-tp14956784p14956784.html
>> > Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/how-to-create-custom-TypeHandlerCallback-to-trim-string-whitespace-tp14956784p15028271.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>
>

--
View this message in context: http://www.nabble.com/how-to-create-custom-TypeHandlerCallback-to-trim-string-whitespace-tp14956784p15029467.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


------=_Part_16442_30100543.1201040635569--