ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Poitras Christian <Christian.Poit...@ircm.qc.ca>
Subject RE: Question about Dynamic and iterator
Date Tue, 23 Jun 2009 13:45:28 GMT
I would try
<select id="getMyInfi" resultClass="com.myclass.Table1"
parameterClass="java.util.List">

SELECT col1, col2 FROM table1
<dynamic prepend="where">
<iterate prepend="AND" property=""
open="(" close=")" conjunction="OR">
col3=#[]#
</iterate>
</dynamic>
</select>

But, you need to have a type handler registered for the objects in the list or #[]# will be
replaced by toString(). If you list contains Strings or numeric values, it's ok.

Christian

________________________________
From: Ashish Kulkarni [mailto:ashish.kulkarni13@gmail.com]
Sent: Monday, June 22, 2009 4:39 PM
To: user-java@ibatis.apache.org
Subject: Question about Dynamic and iterator

Hi
I have to write a query like below

Select col1, col2 from table1 where col3='ABC' or col3='XYZ'

so i wrote a query like below, will this work, what do i have  to specify for property, i
have specified it as list, will this work, any suggestions

<select id="getMyInfi" resultClass="com.myclass.Table1"
parameterClass="java.util.List">

SELECT col1, col2 FROM table1
<dynamic prepend="where">
<iterate prepend="AND" property="list"
open="(" close=")" conjunction="OR">
col3=#list[]#
</iterate>
</dynamic>
</select>

or should i change it to

<parameterMap id="MyMap" class="java.util.Map">
<parameter property="id" javaType="java.util.List" />
</parameterMap>

<select id="getMyInfi" resultClass="com.myclass.Table1"
parameterMap="MyMap">

SELECT col1, col2 FROM table1
<dynamic prepend="where">
<iterate prepend="AND" property="id"
open="(" close=")" conjunction="OR">
col3=#id[]#
</iterate>
</dynamic>
</select>

Mime
View raw message