This worked like a charm. Thanks for the suggestion. I hadn't really thought of doing this but it makes perfect sense and it's extremely easy.


From: "Niels Beekman" <[EMAIL PROTECTED]> [mailto:"Niels Beekman" <[EMAIL PROTECTED]>]
Sent: Saturday, November 04, 2006 3:35 AM
To: <user-java@ibatis.apache.org>
Subject: RE: discriminator and submap

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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of "Larry Meadors" <[EMAIL PROTECTED]>
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, [EMAIL PROTECTED]
<[EMAIL PROTECTED]>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
> [EMAIL PROTECTED]
> (925) 236-5553
>

Reply via email to