不能添加或更新子行:外键约束失败
来源:4-1 Dao层之新增店铺
慕粉18538215531
2018-07-15
org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`imoceo2o`.`tb_shop`, CONSTRAINT `fk_shop_shopcate` FOREIGN KEY (`shop_category_id`) REFERENCES `tb_shop_category` (`shop_category_id`))
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tb_shop(owner_id,area_id,shop_category_id,shop_name,shop_desc,shop_addr,phone,shop_img,priority,create_time,last_edit_time,enable_status,advice) values (?,?,?,?, ?,?,?,?,?,?,?,?,?)
### Cause:
1回答
-
翔仔
2018-07-15
同学好,请确保你插入的店铺类别id在tb_shop_category里面是存在的
ps:这个问题比较基础 建议加强sql方面的学习042019-04-02
相似问题