I want to get data using a dynamic query or statement using iBATIS.
For example
select * from USERS where ID=1 or ID=12 or ID= 3 or ID=27.....
and I want to pass set of IDs as a List Object.
I want to get data using a dynamic query or statement using iBATIS.
For example
select * from USERS where ID=1 or ID=12 or ID= 3 or ID=27.....
and I want to pass set of IDs as a List Object.
You cam use IN statement
<select id="selectKeys" parameterType="list"
resultMap="selectKeysResultMap">
SELECT COL1,COL2
FROM
TABLE1
WHERE COL1 IN
<foreach item="item" index="index" collection="list" open="("
separator="," close=")">
#{item}
</foreach>
</select>
In your DataConnector add this;
Map<String,Object> inputMap = new HashMap<String,Object>();
Map<String,Object> inputMap = new HashMap<String,Object>();
inputMap.put("idList", idList);
mapper.getMcqAnswers(inputMap);
In your DBMapper.xml add this;
<select id="getMcqAnswers" resultType="your result type">
select id,answers from mcqs where id in
<foreach item="item" index="index" collection="idList" open="(" separator="," close=")">
${item}
</foreach>
</select>