ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Integer to Boolean conversion is opposite from expected behavior
Date Fri, 25 Mar 2005 15:40:49 GMT
Generally when representing a boolean as a CHAR in the database
0=false and 1 and greater = true. But, with my stuff it's more like 1
= true and everything else is false. But, i usually stick to looking
for '0' or '1' in my code for explicit and then assuming false if it
is anything other. Also another semantic is to use 'Y' or 'N'. Anyway,
if you are representing 0 as true that would be a Custom Type Handler
even if we provided a standard type handler.

Brandon


On Fri, 25 Mar 2005 07:34:35 -0800 (PST), Karen Koch
<kmkoch@sbcglobal.net> wrote:
> Having 0 = true seems to me to be the opposite of what I would ever expect...
> 
> --- Mike Zatko <mzatko@boscovs.com> wrote:
> > I have a db table that has a field that has a SMALLINT datatype. This
> > field is being used as a true/false flag. 0 would be true, anything else
> > would be false as would typically happen in C. I set up a result map
> > that looks like the following:
> >
> >     <resultMap id="getBenefitAppliesMap"
> > class="com.boscovs.commerce.promotion.dao.benefit.apply.BenefitApplyDAO">
> >         <result property="totalOrderOn" column="TOTAL_ORDER_ON"
> > jdbcType="SMALLINT" javaType="java.lang.Boolean" nullValue="false"/>
> >     </resultMap>
> >
> > I was thrilled that it worked, but the results were opposite of what I
> > expected. A '0' value would denote false, while anything else was true.
> > Anybody know whats going on?
> >
> > --
> > Michael H. Zatko
> > Java Enterprise Developer
> > Boscov's Information Services
> > Work: 610-929-7317
> > Home: 610-376-1624
> > Page: 610-736-4460
> >
> >
>

Mime
View raw message