英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论