ibatis中动态语句的iterate标签
2012-10-12 11:28:45 来源:WEB开发网核心提示: 查询条件dtopublic class queryCondition{private String[] stuIds;private String name;}查询sqlMap<select id="selectStu" parameterClass="cn.xy.queryCon
查询条件dto
public class queryCondition
{
private String[] stuIds;
private String name;
}
查询sqlMap
<select id="selectStu" parameterClass="cn.xy.queryCondition" resultClass="cn.xy.Student">
select id,name from student
<dynamic prepend="where">
<isNotNull property="stuIds" prepend="and">
<iterate property="stuIds" open="id in (" close=")" conjuction=",">
#stuIds[]#
</iterate>
</isNotNull>
<isNotNull property="name" prepend="and">
name like '%$name$%'
</isNotNull>
</dynamic>
</select>
在查询条件中有一个数组stuIds,在动态标签中进行遍历,看每一个student的id是否在该数组中
更多精彩
赞助商链接