Nevermind, as long as there's a workaround, that should be okay J

Appreciate your help ;)

 

 

From: Brandon Goodin [mailto:brandon.goo...@gmail.com] 
Sent: Wednesday, 1 April 2009 20:07
To: user-java@ibatis.apache.org
Subject: Re: Problem with prepend

 

You got me. It is a bug and your code should work without this hack. I need to 
go in and fix the code. The release would likely not be for a while though.

Brandon

On Wed, Apr 1, 2009 at 1:48 AM, Winarto <wina...@fermat.eu> wrote:

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

 

Cheers,

Winarto

 

From: Brandon Goodin [mailto:brandon.goo...@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">
...
</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 <wina...@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

 

 

 

Reply via email to