ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winarto" <wina...@fermat.eu>
Subject Problem with prepend
Date Fri, 27 Mar 2009 08:55:01 GMT
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 prepend="AND" property="context_Id">

                context_id = #context_Id#


            <isNotNull prepend="AND" property="position">

                position = #position#


            <isNull prepend="AND" property="position">

                position = 0




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
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.





View raw message