This article is reproduced to http://www.cnblogs.com/baby-lijun/p/5908088.html
This is the interface defined in my Esdtemplatesealmapper.java.
Public list<esdtemplateseal> Getfilteoutseal (@Param ("filterlist") list<string> List, @Param ("TemplateID ") String TemplateID);
And then my esdtemplatesealmapper.xml inside of the SQL is like this:
<select id= "Getfilteoutseal" resultmap= "Base_result_map" >
select t.template_id, t.seal_id, T.SEAL_TYPE, T. DATA_SRC, t.version from
esd_template_seal t
where T.template_id=#{templateid,jdbctype=varchar} and
T. Seal_type not
in <foreach item= "item" collection= "List" separator= "," open= "(" close= ")" index= "" >
#{0}< C6/></foreach>
</select>
It has been written in this way:
<select id= "Getfilteoutseal" resultmap= "Base_result_map" >
select t.template_id, t.seal_id, T.SEAL_TYPE, T. DATA_SRC, t.version from
esd_template_seal t
where T.template_id=#{templateid,jdbctype=varchar} and
T. Seal_type not
in <foreach item= "item" collection= "List" separator= "," open= "(" close= ")" index= "" >
#{ filterlist}
</foreach>
</select>
The console is reported similar:
Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.binding.BindingException: Parameter ' list ' not found. Available parameters are [TemplateID, param1, param2, ValueList]
Question,
The Final Solution is:
<select id= "GetFilteOutSeal2" parametertype= "map" resultmap= "Base_result_map" >
select t.template_id, T. seal_id, T.seal_type, T.data_src, t.version from
esd_template_seal t
where t.template_id=#{id} and
T.seal _type not
in <foreach item= "item" collection= "FilterList" separator= "open=" ("close=") "index=" Index >
#{item}
</foreach>
</select>
Ps:foreach inside the collection should put something, the wrong understanding is placed in java.util.List, in fact, this type should be the same as our @param binding parameter name