You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "jonte.eriksson" <jo...@gmail.com> on 2009/11/30 19:24:24 UTC

choose and otherwise

Hi,

I've been trying out iBATIS 3.0 beta 5 and according to the documentation
the <choose>, <when> and <otherwise> should work as a normal switch case. I
have a merge update statement and uses a choose like following:

<choose>
     <when test="#{booleanProperty}">
                WHEN NOT MATCHED THEN
                INSERT (column)
                    VALUES (temp.column)
      </when>
      <otherwise>
                WHEN MATCHED THEN
                DELETE
      </otherwise>
</choose>

The problem is that the <otherwise> section is never included, no matter of
the value of the booleanProperty.

If I change to using <if> it works.

<if test="#{booleanProperty}">
         WHEN NOT MATCHED THEN
         INSERT (column)
             VALUES (temp.column)
</if>
<if test="#{!booleanProperty}">
         WHEN MATCHED THEN
                DELETE
</if>

Is this a bug in the <choose> tag or have I misunderstood how it is supposed
to work?

Thanks for a great framwork!
/Jonas
-- 
View this message in context: http://old.nabble.com/choose-and-otherwise-tp26579494p26579494.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: choose and otherwise

Posted by Martin Ellis <el...@gmail.com>.
On Wed, Dec 2, 2009 at 2:54 PM, jonte.eriksson <jo...@gmail.com> wrote:
> But I still got some issues when using a single parameter, like boolean.
> What do I write in the test expression to test that value?
> <if test="id"> does not match when the parameter is set to true.

You could try:
  <if test="_parameter">
... which I think should work (haven't tested).

I must admit, I tend to use Collections.singletonMap(), and pass that
as a parameter if I want to refer to a single parameter by name.


Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: choose and otherwise

Posted by "jonte.eriksson" <jo...@gmail.com>.
My example was wrong in the test expression.

The test expression should not include the #{prop} syntax, just "prop".
Actually I did manage to get it right in other places.

But I still got some issues when using a single parameter, like boolean.
What do I write in the test expression to test that value?
<if test="id"> does not match when the parameter is set to true.

Cheers,
Jonas


jonte.eriksson wrote:
> 
> https://issues.apache.org/jira/browse/IBATIS-704
> 
> 
> Clinton Begin wrote:
>> 
>> Sounds like a bug... I'll have a look at it.  Can you file a Jira ticket
>> for
>> this?
>> 
>> Cheers,
>> Clinton
>> 
>> On Mon, Nov 30, 2009 at 11:24 AM, jonte.eriksson
>> <jo...@gmail.com>wrote:
>> 
>>>
>>> Hi,
>>>
>>> I've been trying out iBATIS 3.0 beta 5 and according to the
>>> documentation
>>> the <choose>, <when> and <otherwise> should work as a normal switch
>>> case. I
>>> have a merge update statement and uses a choose like following:
>>>
>>> <choose>
>>>     <when test="#{booleanProperty}">
>>>                WHEN NOT MATCHED THEN
>>>                INSERT (column)
>>>                    VALUES (temp.column)
>>>      </when>
>>>      <otherwise>
>>>                WHEN MATCHED THEN
>>>                DELETE
>>>      </otherwise>
>>> </choose>
>>>
>>> The problem is that the <otherwise> section is never included, no matter
>>> of
>>> the value of the booleanProperty.
>>>
>>> If I change to using <if> it works.
>>>
>>> <if test="#{booleanProperty}">
>>>         WHEN NOT MATCHED THEN
>>>         INSERT (column)
>>>             VALUES (temp.column)
>>> </if>
>>> <if test="#{!booleanProperty}">
>>>         WHEN MATCHED THEN
>>>                DELETE
>>> </if>
>>>
>>> Is this a bug in the <choose> tag or have I misunderstood how it is
>>> supposed
>>> to work?
>>>
>>> Thanks for a great framwork!
>>> /Jonas
>>> --
>>> View this message in context:
>>> http://old.nabble.com/choose-and-otherwise-tp26579494p26579494.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/choose-and-otherwise-tp26579494p26610189.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: choose and otherwise

Posted by "jonte.eriksson" <jo...@gmail.com>.
https://issues.apache.org/jira/browse/IBATIS-704


Clinton Begin wrote:
> 
> Sounds like a bug... I'll have a look at it.  Can you file a Jira ticket
> for
> this?
> 
> Cheers,
> Clinton
> 
> On Mon, Nov 30, 2009 at 11:24 AM, jonte.eriksson
> <jo...@gmail.com>wrote:
> 
>>
>> Hi,
>>
>> I've been trying out iBATIS 3.0 beta 5 and according to the documentation
>> the <choose>, <when> and <otherwise> should work as a normal switch case.
>> I
>> have a merge update statement and uses a choose like following:
>>
>> <choose>
>>     <when test="#{booleanProperty}">
>>                WHEN NOT MATCHED THEN
>>                INSERT (column)
>>                    VALUES (temp.column)
>>      </when>
>>      <otherwise>
>>                WHEN MATCHED THEN
>>                DELETE
>>      </otherwise>
>> </choose>
>>
>> The problem is that the <otherwise> section is never included, no matter
>> of
>> the value of the booleanProperty.
>>
>> If I change to using <if> it works.
>>
>> <if test="#{booleanProperty}">
>>         WHEN NOT MATCHED THEN
>>         INSERT (column)
>>             VALUES (temp.column)
>> </if>
>> <if test="#{!booleanProperty}">
>>         WHEN MATCHED THEN
>>                DELETE
>> </if>
>>
>> Is this a bug in the <choose> tag or have I misunderstood how it is
>> supposed
>> to work?
>>
>> Thanks for a great framwork!
>> /Jonas
>> --
>> View this message in context:
>> http://old.nabble.com/choose-and-otherwise-tp26579494p26579494.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/choose-and-otherwise-tp26579494p26587923.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: choose and otherwise

Posted by Clinton Begin <cl...@gmail.com>.
Sounds like a bug... I'll have a look at it.  Can you file a Jira ticket for
this?

Cheers,
Clinton

On Mon, Nov 30, 2009 at 11:24 AM, jonte.eriksson
<jo...@gmail.com>wrote:

>
> Hi,
>
> I've been trying out iBATIS 3.0 beta 5 and according to the documentation
> the <choose>, <when> and <otherwise> should work as a normal switch case. I
> have a merge update statement and uses a choose like following:
>
> <choose>
>     <when test="#{booleanProperty}">
>                WHEN NOT MATCHED THEN
>                INSERT (column)
>                    VALUES (temp.column)
>      </when>
>      <otherwise>
>                WHEN MATCHED THEN
>                DELETE
>      </otherwise>
> </choose>
>
> The problem is that the <otherwise> section is never included, no matter of
> the value of the booleanProperty.
>
> If I change to using <if> it works.
>
> <if test="#{booleanProperty}">
>         WHEN NOT MATCHED THEN
>         INSERT (column)
>             VALUES (temp.column)
> </if>
> <if test="#{!booleanProperty}">
>         WHEN MATCHED THEN
>                DELETE
> </if>
>
> Is this a bug in the <choose> tag or have I misunderstood how it is
> supposed
> to work?
>
> Thanks for a great framwork!
> /Jonas
> --
> View this message in context:
> http://old.nabble.com/choose-and-otherwise-tp26579494p26579494.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>