mybatis Mapper.xml中parameterType为object类型的处理方式

1.目标语句
select * from test where id in(1,2,3);

2.Book.java中定义ArrayList类型
private List bookIdList;

public void setBookIdList(List bookIdList) {
        this.bookIdList = bookIdList;
}

3.在controller中调用

List<Integer>list = new ArrayList<Integer>();
Book Book = new Book();
book.setBookIdList(list);

4.Mapper.xml中定义,注意parameterType的值,以及foreach的用法

这样拼接出来的sql语句就是目标语句

你可能感兴趣的:(mybatis Mapper.xml中parameterType为object类型的处理方式)