Mybatis中动态sql语句——ForEach语句 2018-09-02 Mybatis 123456789<!-- 定义根据多个部门ID查询部门相关部门信息的SQL语句 ,resultMap的值是指集合里元素的类型,parameterType不用指定 --><select id="selectListUseForeach" parameterType="Integer[]" resultMap="deptResultMap"> select * from dept where dept_id in <!-- collection="array或list",array用来对应参数为数组,list对应参数为 集合 --> <foreach collection="array" item="deptId" open="(" separator="," close=")"> #{deptId} </foreach></select> < Mybatis中关联查询和resultMap使用 Spring中的事物管理 >