唯一索引或主键冲突,在Spring Boot JPA项目中

huangapple go评论106阅读模式
英文:

Unique index or primary key violation , In Spring Boot JPA project

问题

org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: 唯一索引或主键违规: "PUBLIC.CR_BOOK_DTL(BOOK_ID) ( /* key:0 */ 0, NULL, NULL, NULL)"; SQL 语句:
insert into cr_book_dtl (aurthor_name, book_name, price, book_id) values (?,?,?,?) [23505-214]

在我的Spring Boot JPA项目中遇到此错误。
请提供故障排除。

尝试在表中插入记录。

英文:

org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.CR_BOOK_DTL(BOOK_ID) ( /* key:0 */ 0, NULL, NULL, NULL)"; SQL statement:
insert into cr_book_dtl (aurthor_name,book_name,price,book_id) values (?,?,?,?) [23505-214]

Getting This Error in My Spring Boot JPA Project.
Please Provide Troubleshoot.

Trying to insert record in table

答案1

得分: 1

这意味着您正在尝试将新记录插入到“cr_book_dtl”表中,并为“aurthor_name”、“book_name”、“price”和“book_id”列提供了值。然而,您为“book_id”列提供的值已经作为主键或唯一索引存在于表中,这导致了约束冲突。

换句话说,您正在尝试插入一个具有已经存在于表中的“book_id”值的记录。

尝试增加唯一标识并重新插入记录。

英文:

This means that you are trying to insert a new record into the "cr_book_dtl" table and you are supplying values for the "aurthor_name", "book_name", "price" and "book_id" columns. However, the value you are supplying for the "book_id" column already exists in the table as a primary key or in a unique index, which is causing the constraint violation.

In other words, you are trying to insert a record with a value of "book_id" that already exists in the table.

Try increasing the unique ID and reinserting the record.

huangapple
  • 本文由 发表于 2023年8月10日 15:27:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76873477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定