Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 38799 invoked from network); 15 Feb 2007 23:26:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Feb 2007 23:26:01 -0000 Received: (qmail 9103 invoked by uid 500); 15 Feb 2007 23:26:09 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 8502 invoked by uid 500); 15 Feb 2007 23:26:07 -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 8491 invoked by uid 99); 15 Feb 2007 23:26:07 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 15:26:07 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of arthomps@gmail.com designates 66.249.92.173 as permitted sender) Received: from [66.249.92.173] (HELO ug-out-1314.google.com) (66.249.92.173) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 15:25:57 -0800 Received: by ug-out-1314.google.com with SMTP id m2so65376ugc for ; Thu, 15 Feb 2007 15:25:35 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=eVFNhI76StUDT8cVRCLfzyz/d6T2qF7WottM5oe6QdrP2AYkT6QPzvVgiuj132KENvqBIXbMUUOzvRgfkk4dIPu9jCO1RsfzcCww+1g2Dhx62wugl5QRQzna6L5KjfZT7QBotsq79zLcYqrdYJTr4NI7o5A60dOxe6qc/nWOzi8= Received: by 10.115.46.9 with SMTP id y9mr1544670waj.1171581934406; Thu, 15 Feb 2007 15:25:34 -0800 (PST) Received: by 10.114.149.9 with HTTP; Thu, 15 Feb 2007 15:25:34 -0800 (PST) Message-ID: <94c6c2b70702151525k7a43b5dftf0f035f031446e5f@mail.gmail.com> Date: Thu, 15 Feb 2007 18:25:34 -0500 From: "Andy Thompson" To: user-java@ibatis.apache.org Subject: Re: silly question regarding cast from char to int In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_54362_3450016.1171581934103" References: <94c6c2b70702151411s4ad497bbs65cbd3862d75fcd7@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_54362_3450016.1171581934103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline thanks jeff, i was expecting that - it pains me though. i was hoping to reuse the dao code base across multiple datasources. this makes that less elegant because i can't assume the other datasources will have that same bad database design. -andy On 2/15/07, Jeff Butler wrote: > > The easiest resolution is to store numbers in number fields in the > database! But I understand if you can't change the database. > > It's really best to change the DAOs. As an alternative, you could change > the SQL with some database specific code. For example, in DB2 you could do > this: > > select * > from some_table > where integer(database_id) = #java_id# > > However be warned that this is a very poor performer and will cause table > scans. So it's best to change it in the DAO. > > Jeff Butler > > > > > > > > On 2/15/07, Andy Thompson wrote: > > > > in my database - i've got a value that's of type char. for example > > "0000009". the dao is passing back a request by id where id is 9. So > > there's no match. > > > > so select * from some_column where database_id = #java_id# returns > > null. but select * from some_column where database_id="0000009" returns > > true. > > > > I'd prefer to not have to modify the dao making the request to add 0s to > > it cause that seems dumb and I can't change the database. > > what's the easiest resolution here? > > > > -- > > Andrew R. Thompson > > Currently in D.C. Consulting > > > -- Andrew R. Thompson Currently in D.C. Consulting ------=_Part_54362_3450016.1171581934103 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline thanks jeff,

i was expecting that - it pains me though.  i was hoping to reuse the dao code base across multiple datasources.  this makes that less elegant because i can't assume the other datasources will have that same bad database design.

-andy

On 2/15/07, Jeff Butler <jeffgbutler@gmail.com> wrote:
The easiest resolution is to store numbers in number fields in the database!  But I understand if you can't change the database.
 
It's really best to change the DAOs.  As an alternative, you could change the SQL with some database specific code.  For example, in DB2 you could do this:
 
select *
from some_table
where integer(database_id) = #java_id#
 
However be warned that this is a very poor performer and will cause table scans.  So it's best to change it in the DAO.
 
Jeff Butler
 
 
 
 


 
On 2/15/07, Andy Thompson <arthomps@gmail.com > wrote:
in my database - i've got a value that's of type char.  for example "0000009".  the dao is passing back a request by id where id is 9.  So there's no match.

so select * from some_column where database_id = #java_id# returns null.  but select * from some_column where database_id="0000009" returns true.
 
I'd prefer to not have to modify the dao making the request to add 0s to it cause that seems dumb and I can't change the database. 
what's the easiest resolution here?

--
Andrew R. Thompson
Currently in D.C. Consulting




--
Andrew R. Thompson
Currently in D.C. Consulting ------=_Part_54362_3450016.1171581934103--