ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: silly question regarding cast from char to int
Date Thu, 15 Feb 2007 22:25:14 GMT
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

Mime
View raw message