insertByMap 报错
来源:13-2 mybatis注解方式使用_A
战神40
2020-04-01
单元测试如下
@Test
public void insertByMap() {
Map<String,Object> map=new HashMap<>();
map.put("category_name","我的最爱");
map.put("category_type",101);
int result=mapper.insertByMap(map);
Assert.assertEquals(1,result);
}
报错了,感觉没问题呀
org.springframework.dao.DataIntegrityViolationException:
Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘category_name’ cannot be null
The error may involve com.imooc.dataobject.mapper.ProductCategoryMapper.insertByMap-Inline
The error occurred while setting parameters
SQL: insert into product_category(category_name, category_type) values (?, ?)
Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘category_name’ cannot be null
; Column ‘category_name’ cannot be null; nested exception is java.sql.SQLIntegrityConstraintViolationException: Column ‘category_name’ cannot be null
写回答
2回答
-
战神40
提问者
2020-04-06
师兄,每次你回答的时候问题我就解决了
022020-04-07 -
廖师兄
2020-04-06
看看insertByMap是怎么写的,应该是该方法上面的@Insert内容写错了。
00
相似问题