ibatis中传入list作为in的条件 传入Map

    <select id="getTestPaper" parameterClass="java.util.HashMap" resultMap="get-test-paper">
      <![CDATA[ select * from sas_test_paper as s_t left join sas_test_department as s_t_d on s_t.test_id=s_t_d.t_id  where s_t_d.department_id in ]]>
       <iterate property="list" open="(" close=")"  conjunction=",">
          #list[]#
       </iterate>
       and test_name not in
       (select s_result.test_name from sas_test_result as s_result left join sas_test_paper as s_paper on s_result.start_time=s_paper.start_time
        and s_result.end_time=s_paper.end_time
        where um_name=#umName# and s_result.flag='0' and s_paper.flag='0') and <![CDATA[start_time<now() and now()<end_time]]> and  s_t.flag='0' and s_t_d.flag='0'
    </select>

 

由于传入的类型是HashMap(因为还有其他参数要传入),此时iterate中红色部分必须要加上,不然会报错:ParameterObject or property was not a Collection, Array or Iterator.)

一开始看很多人都是没有写 property 这个属性,那是传入的参数就是集合或者数组之类的,对于map或者其他对象中包含list的 ,property属性必须写上。

posted on 2016-02-18 17:44  java外行  阅读(1046)  评论(0)    收藏  举报

导航