Java代码 123456789 Map<String,Object> ibatisParam = new HashMap<String, Object>( ); ibatisParam.put( "keyA","valueA" ); List<String> list = new ArrayList<String>( ); list.add( "namespace1" ); list.add( "namespace2" ); ibatisParam.put( "namespaces",list ); 1234567891011121314 <select id="listNodeByCriteria" parameterClass="java.util.Map" resultMap="NodeWithPropertyResult"> select <include refid="NodeColumnsWithId"/> from node <dynamic prepend=" where "> <isNotNull property="namespaces"> namespace in <iterate property="namespaces" open="(" conjunction="," close=")"> #namespaces[]# </iterate> </isNotNull> </dynamic> order by id limit #querySize# offset #startRow# </select> list 对象版本 123456 <iterate property="namespaces" open="(" conjunction="," close=")"> <!--每一个NameSpace实例的name属性通过namespaces[].name获取--> #namespaces[].name# </iterate> MYBATIS xml 1234567891011 <!--List:forech中的collection属性类型是List,collection的值必须是:list,item的值可以随意,Dao接口中参数名字随意 --> <select id="getEmployeesListParams" resultType="Employees"> select * from EMPLOYEES e where e.EMPLOYEE_ID in <foreach collection="list" item="employeeId" index="index" open="(" close=")" separator=","> #{employeeId} </foreach> </select> 赞微海报分享
近期评论