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