myBatis 传入ArrayList 参数的正确用法get

1.参数原型xml

List<String> notFoundId = new ArrayList<String>();get

2.dao层传参原型

public List<YdhcData> getAllOffice(List<String> notFoundId);it

3.myBatis xml读取io

惟一值得注意的地方是:test

通常来讲咱们都是经过传参的名字去匹配参数的,可是myBatis的collection填的是参数的类型foreach

<select id="getAllOffice" resultType="YdhcData">
    select so.id,so.parent_id,so.name 
    from sys_office so
    <where>
    <if test="list!=null and list.size()!=0">
      so.id in (
      <foreach collection="list" item="pid" index="index" separator=",">
       #{pid}
      </foreach>
      )
    </if>
    </where>
    </select>List

相关文章
相关标签/搜索