Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘xxx‘ for key ‘xxx‘

文章描述了一个数据库操作时遇到的问题,具体是尝试插入的数据违反了数据库表中idx_party_code_and_branch_code这个唯一索引的约束,导致Duplicate-entry异常。解决方案是检查并修改重复的party_code和branch_code,或者删除该唯一索引。
摘要由CSDN通过智能技术生成
错误详情:

### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry 'f433bda2158d426e98fa7a5d29c61098-49adb23841asw3118' for key 'idx_party_code_and_branch_code'
### The error may exist in com/arpa/ntocc/common/mapper/arpapay/ArpaMerchantMapper.java (best guess)
### The error may involve com.arpa.ntocc.common.mapper.arpapay.ArpaMerchantMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO base_arpa_merchant (code, branch_code, party_code, party_type, merchant_type, merchant_name, merchant_short_name, contact_phone, contact_mail, certificate_type, certificate_number, certificate_validity_begin, certificate_validity_end, certificate_photo_a_url, certificate_photo_b_url, province, province_name, city, city_name, county, county_name, address, card_type, card_number, card_bank_phone, card_acc_name, bank_name, bank_code, bank_child_name, bank_child_code, card_acc_type, lep_name, lep_phone, lep_certificate_type, lep_certificate_number, lep_certificate_validity_begin, lep_certificate_validity_end, lep_certificate_photo_a_url, lep_certificate_photo_b_url, bank_card_code, modified_by_name, created_by, modified_by, gmt_created, gmt_modified) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
### Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry 'f433bda2158d426e98fa7a5d29c61098-49adb23841asw3118' for key 'idx_party_code_and_branch_code'
; Duplicate entry 'f433bda2158d426e98fa7a5d29c61098-49adb23841asw3118' for key 'idx_party_code_and_branch_code'; nested exception is java.sql.SQLIntegrityConstraintViolationException: Duplicate entry 'f433bda2158d426e98fa7a5d29c61098-49adb23841asw3118' for key 'idx_party_code_and_branch_code'
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243) ~[spring-jdbc-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.2.0.RELEASE.jar!/:5.2.0.RELEASE]

错误原因数据库加了唯一索引idx_party_code_and_branch_code,索引具体字段是party_code、branch_code,也就是说相同的party_code、branch_code在数据库中只能有一条,把索引删除就好了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]:返回到login页面时的url为http://localhost:8080/register?userName=%E8%B5%B5%E5%85%AD&identityCode=456795555225452&email=457698826%40qq.com&mobile=1550000&gender=0&loginName=six&password=,这时项目又将数据存储了一遍造成了数据重复。引用\[2\]:Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '1' for key 'x_mu.PRIMARY' 问题:为什么会出现"Duplicate entry '1' for key 'x_mu.PRIMARY'"的错误? 回答: 这个错误是由于数据库中的唯一键约束引起的。在给数据库插入数据时,如果插入的数据与已有数据的唯一键冲突,就会出现这个错误。在你提供的引用中,可以看到在返回到login页面时,项目又将数据存储了一遍,导致了数据的重复。而数据库中的唯一键约束要求每条记录的唯一键值都是唯一的,因此当插入重复的唯一键值时,就会出现"Duplicate entry '1' for key 'x_mu.PRIMARY'"的错误。这个错误提示中的'1'是指重复的唯一键值,'x_mu.PRIMARY'是指唯一键的名称。 #### 引用[.reference_title] - *1* [Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry ‘‘six‘ for keyuser_...](https://blog.csdn.net/m0_52163608/article/details/119719084)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值