1.错误详细代码:

org.springframework.dao.DuplicateKeyException : ### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1-[RP58A]' for key 'UNQ_BRAND_PATTERN'
### The error may involve com.zcckj.storeshow.mapper.TyreBrandPatternSettingMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO TYRE_BRAND_PATTERN_SETTING  ( id,tyre_brand_id,tyre_brand_name,tyre_pattern_name,tyre_ins_flag,photo_url,create_by,create_tm,tyre_type,tyre_rim ) VALUES( ?,?,?,?,?,?,?,?,?,? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1-[RP58A]' for key 'UNQ_BRAND_PATTERN'
;

2.错误分析:

关键的地方:

DUPLICATE entry '1-[RP58A]' FOR KEY 'UNQ_BRAND_PATTERN';

nested exception IS com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException : DUPLICATE entry '1-[RP58A]' FOR KEY 'UNQ_BRAND_PATTERN'

    Duplicate重复的意思,这个问题的话原因是在调用持久层类的进行保存或更新的时候,跟主键或唯一性约束(索引)冲突了,我当前表产生冲突的约束是’UNQ_BRAND_PATTERN’

3.可能的解决办法:

  • 调用持久层类的进行保存或更新前进行条件约束
  • 删除唯一性索引
  • 改唯一性索引为普通索引
  • 捕获异常处理
Logo

更多推荐