ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: discriminator and submap
Date Sat, 04 Nov 2006 11:35:02 GMT
If only if/else behaviour is required, why not create an additional
column? Something like:

 

SELECT *, CASE WHEN part_no IS NULL THEN 0 ELSE 1 END AS hasPartNo

FROM yourTable

 

    <discriminator column="hasPartNo" javaType="java.lang.Boolean"
jdbcType="BIT">

      <subMap value="1" resultMap="SupportItemResult_withPart" />

      <subMap value="0" resultMap="SupportItemResult_withoutPart" />

    </discriminator>

 

Niels

________________________________

From: Christopher.Mathrusse@sybase.com
[mailto:Christopher.Mathrusse@sybase.com] 
Sent: zaterdag 4 november 2006 1:42
To: user-java@ibatis.apache.org
Subject: RE: discriminator and submap

 

Well I did something similar but I still need to perform the 'else'.

 

    <discriminator column="part_no" javaType="java.lang.String"
jdbcType="VARCHAR" nullValue="NULL">
      <subMap value="NULL" resultMap="SupportItemResult" />
    </discriminator>

 

My problem is that the above will apply the resultMap if the field
part_no is null, but how do I apply a different resultMap if part_no is
not null. I don't want to test for all possible values I only want a
simple if/else basically.

 

________________________________

From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf
Of "Larry Meadors" <lmeadors@apache.org>
Sent: Friday, November 03, 2006 4:31 PM
To: user-java@ibatis.apache.org
Subject: Re: discriminator and submap

I'd probably do something like NVL(field, 'someMagicNullString') in 
the sql to make sure that it wasn't null. :-/ 

Crude, but effective. 

Larry 


On 11/3/06, Christopher.Mathrusse@sybase.com 
wrote: 
> 
> 
> Can I use the discriminator and sub map to test for null values?
Meaning if 
> I define the discriminator for a field and I want to apply one result
map if 
> the field is null and another if it is not, how do I define this? 
> 
> Thanks.... 
> 
> Chris Mathrusse 
> christopher.mathrusse@sybase.com 
> (925) 236-5553 
> 


Mime
View raw message