0.报错详情
insert语句插入的时候报错。
报错详情如下:
org.springframework.dao.DuplicateKeyException: \r\n### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘f098779b-3148-4bf5-b553-3274416dacd8-922a6ffe-142d-495d-b5d1-987’ for key ‘uni_company_binding_product’\r\n### The error may involve com.xxx.xxxx.buildingmaterials.dao.CompanyBindingProductMapper.insertCompanyBindingProduct-Inline\r\n### The error occurred while setting parameters\r\n### SQL: INSERT INTO company_binding_product
(id
, org_id
, product_id
, certificate_number
, valid_time
, attachment_url
, type
,classification
) VALUES (?,?,?,?,?,?,?,?)\r\n### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘f098779b-3148-4bf5-b553-3274416dacd8-922a6ffe-142d-495d-b5d1-987’ for key ‘uni_company_binding_product’\n; SQL []; Duplicate entry ‘f098779b-3148-4bf5-b553-3274416dacd8-922a6ffe-142d-495d-b5d1-987’ for key ‘uni_company_binding_product’; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry ‘f098779b-3148-4bf5-b553-3274416dacd8-922a6ffe-142d-495d-b5d1-987’ for key ‘uni_company_binding_product’"
主要原因是这个表设置了主键,主键唯一,而插入的数据重复了,所以会报这个错。
另外,不要忽略了还有联合主键这个,我的报错就是因为联合主键,id本身是UUID不会重复,但是和联合主键一块就出现了重复的情况,所以这个也要排查一下。