I want to iterate through the list, but I am getting exception
org.apache.ibatis.mapping.SqlMapperException: The expression 'list' evaluated to a null value.
My java code:
public List<SearchVO> getSearchResultByParams(List<String> selectedGroups) {
Map map = new HashMap(1);
map.put("selectedGroups", selectedGroups);
return MyMapper.getSearchResultByParams(map);
}
MyMapper.xml:
<select id="getSearchResultByParams" parameterType="map" resultMap="SearchResultMap">
SELECT *
FROM WORK
WHERE ID IN
<foreach item="selectedGroups" collection="list" open="(" separator="," close=")">
#{selectedGroups}
</foreach>
</select>
first make sure you had set alias map for java.util.HashMap in mybatis-config file typeAliases tag
collection must be the key for you list in your map
the doc may help you http://mybatis.github.io/mybatis-3/dynamic-sql.html