iBatis 3: dynamic sql and numeric property type problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

iBatis 3: dynamic sql and numeric property type problem

Andreas Niemeyer-2
Hi,

how can I deal with numeric class properties for dynamic sql in iBatis
3.x? In the older 2.x release there exist a `<isGreaterThan>' tag and
the user guide for 3.x only mentioned the <if> condition. For that, I
get a NumberFormatException:

Caused by: java.lang.NumberFormatException: For input string: "{0=null}"


The example looks like:

<select id="getSomeList" resultType="SomeClass"
parameterType="SomeConditionClass">
  select
                        <include refid="someColumns"/>
                from
                        hmm_t t, context_x x
                where
                        t.id = x.id_hmm
                       
                        <if test="#{id} != -1">
                                and x.id = #{id}
                        </if>
                       
</select>


Thank you in advance,
Andreas



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: iBatis 3: dynamic sql and numeric property type problem

Larry Meadors
I think you can just say <if test="id != -1">, but I haven't done this
exact thing yet.

Since we're using ognl for expressions, here's where I'd look:
http://www.opensymphony.com/ognl/html/LanguageGuide/index.html

Also, you should join and post to the new list at google:
http://groups.google.com/group/mybatis-user instead.

At this point, there are no plans to continue the ibatis project at
Apache, the project (including the development team) has moved and it
will live on as mybatis at google code instead.

Larry

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: iBatis 3: dynamic sql and numeric property type problem

Andreas Niemeyer-2
In reply to this post by Andreas Niemeyer-2
Sorry, I had a missunderstanding, it works this way:

...
<if test="id != -1">
        and x.id = #{id}
</if>
...

Andreas Niemeyer schrieb:

> Hi,
>
> how can I deal with numeric class properties for dynamic sql in iBatis
> 3.x? In the older 2.x release there exist a `<isGreaterThan>' tag and
> the user guide for 3.x only mentioned the <if> condition. For that, I
> get a NumberFormatException:
>
> Caused by: java.lang.NumberFormatException: For input string: "{0=null}"
>
>
> The example looks like:
>
> <select id="getSomeList" resultType="SomeClass"
> parameterType="SomeConditionClass">
>          select
>             <include refid="someColumns"/>
>         from
>             hmm_t t, context_x x
>         where
>             t.id = x.id_hmm      
>            
>             <if test="#{id} != -1">
>                 and x.id = #{id}    
>             </if>  
>            
> </select>
>
>
> Thank you in advance,
> Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: iBatis 3: dynamic sql and numeric property type problem

Andreas Niemeyer-2
Hi,
I've another use case for a possible if check:

- if the parameterType long it fails for the if check:

<select id="getMegaList" resultType="Mega" parameterType="long">
    Select
    id, descr, description from mega_t
    <where>
    <if test="id != -1">
                id = #{id}
        </if>
    </where>
  </select>


Thank you in advance,
Andreas



Andreas Niemeyer schrieb:

> Sorry, I had a missunderstanding, it works this way:
>
> ...
> <if test="id != -1">
>     and x.id = #{id}    
> </if>  
> ...
>
> Andreas Niemeyer schrieb:
>> Hi,
>>
>> how can I deal with numeric class properties for dynamic sql in iBatis
>> 3.x? In the older 2.x release there exist a `<isGreaterThan>' tag and
>> the user guide for 3.x only mentioned the <if> condition. For that, I
>> get a NumberFormatException:
>>
>> Caused by: java.lang.NumberFormatException: For input string: "{0=null}"
>>
>>
>> The example looks like:
>>
>> <select id="getSomeList" resultType="SomeClass"
>> parameterType="SomeConditionClass">
>>          select
>>             <include refid="someColumns"/>
>>         from
>>             hmm_t t, context_x x
>>         where
>>             t.id = x.id_hmm                              <if
>> test="#{id} != -1">
>>                 and x.id = #{id}                </if>              
>> </select>
>>
>>
>> Thank you in advance,
>> Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: iBatis 3: dynamic sql and numeric property type problem

Larry Meadors
The ibatis project has moved and been renamed.

It is no longer being maintained as an Apache project, but has moved
(along with the development team) here:

http://www.mybatis.org/

Please join us at the new location by joining the mailing list here:

http://groups.google.com/group/mybatis-user

Larry

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...