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: Problem with prepend
Date Fri, 27 Mar 2009 11:44:26 GMT
 Try adding a prepend to workspace_id.
<isNotNull property="workspace_Id" prepend="BOGUS">
...
</isNotNull>

The reason this occurs is that the dynamic tag has an automatic
removeFirstPrepend="true". Since the isNotNull:position tag is the first to
produce a prepend it removes the prepend from the isNotNull:position.

Brandon

On Fri, Mar 27, 2009 at 3:55 AM, Winarto <winarto@fermat.eu> wrote:

>  Hi All,
>
>
>
> I’m having problem with the following select statement.
>
>
>
>         SELECT * FROM contexts
>
>         <dynamic prepend="WHERE" >
>
>             <isNotNull property="workspace_Id">
>
>                 workspace_id = #workspace_Id#
>
>             </isNotNull>
>
>             <isNotNull prepend="AND" property="context_Id">
>
>                 context_id = #context_Id#
>
>             </isNotNull>
>
>             <isNotNull prepend="AND" property="position">
>
>                 position = #position#
>
>             </isNotNull>
>
>             <isNull prepend="AND" property="position">
>
>                 position = 0
>
>             </isNull>
>
>         </dynamic>
>
>
>
> The data type of property position is java.lang.Integer. My intention is:
> whenever position is not null, use “AND position = ?” and whenever position
> is null, use “AND position = 0”.  However what I got in my debug log is the
> prepend AND before position never come up.
>
> Following is the statement generated:
>
> When position is not null è SELECT * FROM contexts WHERE workspace_Id = ?
>      position = ?
>
> When position is null è SELECT * FROM contexts WHERE workspace_Id = ?
>      position = 0
>
>
>
> I was wondering what’s wrong with my dynamic select statement. I’m using
> IBatis version 2.3.4.726. I tried to debug the source code and found out
> that when it is processing the <isNull> tag, it tries to get the prepend
> attribute of the <dynamic> tag.
>
>
>
> Can anyone enlighten me? Any help is very much appreciated.
>
>
>
> Cheers,
>
> Winarto
>
>
>

Mime
View raw message