我单元测试数据的更新操作,一直报错java.sql.SQLException: Parameter index out of range (13 > number of parameters, which is 12)
表结构:
DROP TABLE IF EXISTS business;
CREATE TABLE business(id int(11) NOT NULL AUTO_INCREMENT COMMENT 主键,img_file_name varchar(200) DEFAULT NULL COMMENT 图片文件名,title varchar(50) DEFAULT NULL COMMENT 标题,subtitle varchar(100) DEFAULT NULL COMMENT副标题,price decimal(11,2) DEFAULT NULL COMMENT价格(单位:元),distance int(11) DEFAULT NULL COMMENT距离(单位:米),number int(11) DEFAULT NULL COMMENT 已售数量,desc varchar(500) DEFAULT NULL COMMENT 描述,city varchar(16) DEFAULT NULL COMMENT 城市,catefory varchar(16) DEFAULT NULL COMMENT 类别,start_total_num int(11) DEFAULT NULL COMMENT 评论星星总数,comment_total_num int(11) DEFAULT NULL COMMENT 评论总次数,
PRIMARY KEY (id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
bean:
private Long id;
private String imgFileName;
private String title;
private String subtitle;
private Double price;
private Integer distance;
private Integer number;
private String desc;
private String city;
private String category;
private Long starTotalNum;
private Long commentTotalNum;
mybatis的update:
```<update id="update">
update business b SET b.img_file_name=#{imgFileName},b.title=#{title},b.subtitle=#{subtitle},b.price=#{price}
,b.distance=#{distance},b.number=#{number},b.desc=#{desc},b.city=#{city},b.category=#{category},b.star_total_num=#{starTotalNum},b.comment_total_num=#{commentTotalNum}
where b.id=#{id}
</update>
单元测试:
@Test
public void update(){
BusinessDto businessDto = new BusinessDto();
Long a = new Long(3);
businessDto.setId(a);
businessDto.setCity("北京");
businessDto.setDesc("啦啦啦啦啦啦");
businessService.modify(businessDto);
}