ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winarto" <wina...@fermat.eu>
Subject RE: Problem with prepend
Date Wed, 01 Apr 2009 06:48:13 GMT
Hi Brandon,


Thanks for your help. Your suggestion works for me.


Your explanation sounds make sense to explain what is happening to my code. However from logical
point of view, my original configuration should be correct, right? Or I missed something in
the documentation J





From: Brandon Goodin [mailto:brandon.goodin@gmail.com] 
Sent: Friday, 27 March 2009 19:44
To: user-java@ibatis.apache.org
Subject: Re: Problem with prepend


Try adding a prepend to workspace_id.  
<isNotNull property="workspace_Id" prepend="BOGUS">

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. 


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