I have a update query in mapper interface using mybatis
final String UPDATE ="update table_addresses "
+ "set postCode= #{postCode}"
+ "where id in"
+ "<foreach item='item' index='index'
collection='addressId' "
+ "open='(' separator=',' close=')'> #{item}
</foreach>";
@Update(UPDATE)
public int updateInformation(@Param("postCode") String postCode ,
@Param("addressId") List<AddressID> addressId);
My AddressId class contains int type addressId:
AddressId {
private int addressId;
}
Now the method where I am calling mapper Interface..I am sending a String postCode and object List addresses.
I am getting below error Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'item' not found. Available parameters are [param1, param2, postCode, addressId]..What Ia m doing wrong here.What is the correct syntax of foreach loop where I can pass addressId which conatins List.