在测试hibernate时出现了如下异常:
[Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"]; SQL was [] for task [Hibernate operation]
org.springframework.dao.DataIntegrityViolationException: Hibernate operation: Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"; nested exception is java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"
java.sql.SQLException: Duplicate key or integrity constraint violation message from server: "Duplicate entry 'rick0@foobar.com' for key 2"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
这个问题找了很久,晕了很久,终于找到了问题的所在。因我在定义数据表字段时加了not null unique,而我一次添加N条记录时的内容一样,主键是自动生成的,所以出问题了。
分享到:
相关推荐
"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'a3b6420a-6724-11ea-b2a3-d773d1d6999f' for key 'callId'\nThe SQL being executed was: INSERT INTO `ly_call` (`call_id`, `mobile`, ...
12. ORA-02291:integrity constraint (约束名) violated - parent key not found - 违反外键约束,父表中缺少相应的主键记录。插入或更新数据时确保满足引用完整性。 13. ORA-02292:integrity constraint ...
- **Target-Based Deduplication**: Reduces storage space requirements by eliminating duplicate data blocks before they reach the target storage. 6. **Cloud Integration**: Offers options for cloud-...
Integrity Constraint Violated--Parent Key Not Found 482 Oracle Not Available 483 Inserted Value Too Large for Column 483 TNS:listener Could Not Resolve SID Given in Connect Descriptor 484 Insufficient...
著名培训机构的LTE培训教材。 深入浅出,从基本概念到深入描述。是一份比较全面的教材。全文367页。有料有内容。是一份难得的教材。 文件比较大,所以拆成3部分。这是part1 ...Principles and Motivation of LTE.........
著名培训机构的LTE培训教材。 深入浅出,从基本概念到深入描述。是一份比较全面的教材。全文367页。有料有内容。是一份难得的教材。 文件比较大,所以拆成3部分。这是part2 ...Principles and Motivation of LTE.........
著名培训机构的LTE培训教材。 深入浅出,从基本概念到深入描述。是一份比较全面的教材。全文367页。有料有内容。是一份难得的教材。 文件比较大,所以拆成3部分。这是part3 ...Principles and Motivation of LTE.........