You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by FranT <ma...@reims-habitat.fr> on 2008/02/01 17:25:04 UTC
My first dynamic statement
Hi there, i'm new ti iBatis and need help for my first dynamic statement.
Here it is:
<resultMap id="getDynam" class="my.ft.kcaldos">
<result property="dndl" column="DNDL"/>
<result property="ncal" column="NCAL"/>
<result property="datcom" column="DATCOM"/>
</resultMap>
<select id="dynamis" parameterClass="java.util.Map"
resultMap="getDynam">
SELECT dndl, ncal, datcom from kcaldos
<dynamic prepend="WHERE">
<isNotNull prepend="AND" property="eced">
eced=#ec#
</isNotNull>
<isNotNull prepend="AND" property="demc">
demc=#dem#
</isNotNull>
</dynamic>
where datcom > to_date('01/01/2007','DD/MM/YYYY')
order by dndl
</select>
When running it, i stil get;
'SELECT dndl, ncal, datcom from kcaldos where datcom >
to_date('01/01/2007','DD/MM/YYYY') order by dndl'
even when the two properties (eced and demc) are not null.
May be i'm missing something somewhere ? Thanks in advance.
Re: My first dynamic statement
Posted by bb...@peapod.com.
Your property names don't match what you have between ##. How about:
<isNotNull prepend="AND" property="eced">
eced=#eced#
</isNotNull>
<isNotNull prepend="AND" property="demc">
demc=#demc#
</isNotNull>
On Feb 1 2008, FranT wrote:
>Hi there, i'm new ti iBatis and need help for my first dynamic statement.
>Here it is:
>
>
><resultMap id="getDynam" class="my.ft.kcaldos">
> <result property="dndl" column="DNDL"/>
> <result property="ncal" column="NCAL"/>
> <result property="datcom" column="DATCOM"/>
> </resultMap>
>
> <select id="dynamis" parameterClass="java.util.Map"
> resultMap="getDynam">
> SELECT dndl, ncal, datcom from kcaldos
> <dynamic prepend="WHERE">
> <isNotNull prepend="AND" property="eced">
> eced=#ec#
> </isNotNull>
> <isNotNull prepend="AND" property="demc">
> demc=#dem#
> </isNotNull>
> </dynamic>
> where datcom > to_date('01/01/2007','DD/MM/YYYY')
> order by dndl
> </select>
>
>When running it, i stil get;
> 'SELECT dndl, ncal, datcom from kcaldos where datcom >
>to_date('01/01/2007','DD/MM/YYYY') order by dndl'
>even when the two properties (eced and demc) are not null.
>May be i'm missing something somewhere ? Thanks in advance.
>
>
>