ORA-02292:违反完整性约束(JSPPROJECTDATABASE.FK_BOOK_ID_BOOK_TABLE)-找到子记录

时间:2019-05-23 18:24:31

标签: java oracle hibernate foreign-keys

我想删除BookOrder的ID值,但是根据休眠和错误提示有SQL语句。

#!/bin/sh

echo "Waiting for postgres..."

while ! nc -z web-db 5432; do
  sleep 0.1
done

echo "PostgreSQL started"

python manage.py run -h 0.0.0.0

Hibernate: select bookorders0_.ORDER_ID as ORDER_ID1_1_0_, bookorders0_.CUSTOMER_ID as CUSTOMER_ID9_1_0_, bookorders0_.ORDER_DATE as ORDER_DATE2_1_0_, bookorders0_.ORDER_STATUS as ORDER_STATUS3_1_0_, bookorders0_.ORDER_TOTAL as ORDER_TOTAL4_1_0_, bookorders0_.PAYMENT_METHOD as PAYMENT_METHOD5_1_0_, bookorders0_.RECIPIENT_NAME as RECIPIENT_NAME6_1_0_, bookorders0_.RECIPIENT_PHONE as RECIPIENT_PHONE7_1_0_, bookorders0_.SHIPPING_ADDRESS as SHIPPING_ADDRESS8_1_0_, orderdetai1_.ORDER_ID as ORDER_ID4_5_1_, orderdetai1_.BOOK_ID as BOOK_ID3_5_1_, orderdetai1_.BOOK_ID as BOOK_ID3_5_2_, orderdetai1_.ORDER_ID as ORDER_ID4_5_2_, orderdetai1_.QUANTITY as QUANTITY1_5_2_, orderdetai1_.SUBTOTAL as SUBTOTAL2_5_2_, book2_.BOOK_ID as BOOK_ID1_0_3_, book2_.AUTHOR as AUTHOR2_0_3_, book2_.CATEGORY_ID as CATEGORY_ID11_0_3_, book2_.DESCRIPTION as DESCRIPTION3_0_3_, book2_.IMAGE as IMAGE4_0_3_, book2_.ISBN as ISBN5_0_3_, book2_.LAST_UPDATED_DATE as LAST_UPDATED_DATE6_0_3_, book2_.PRICE as PRICE7_0_3_, book2_.PUBLISH_DATE as PUBLISH_DATE8_0_3_, book2_.QUANTITY as QUANTITY9_0_3_, book2_.TITLE as TITLE10_0_3_ from BOOKORDERS bookorders0_ left outer join DETAILORDER orderdetai1_ on bookorders0_.ORDER_ID=orderdetai1_.ORDER_ID left outer join BOOK book2_ on orderdetai1_.BOOK_ID=book2_.BOOK_ID where bookorders0_.ORDER_ID=? Hibernate: select detailorde0_.BOOK_ID as BOOK_ID3_5_0_, detailorde0_.ORDER_ID as ORDER_ID4_5_0_, detailorde0_.BOOK_ID as BOOK_ID3_5_1_, detailorde0_.ORDER_ID as ORDER_ID4_5_1_, detailorde0_.QUANTITY as QUANTITY1_5_1_, detailorde0_.SUBTOTAL as SUBTOTAL2_5_1_, bookorders1_.ORDER_ID as ORDER_ID1_1_2_, bookorders1_.CUSTOMER_ID as CUSTOMER_ID9_1_2_, bookorders1_.ORDER_DATE as ORDER_DATE2_1_2_, bookorders1_.ORDER_STATUS as ORDER_STATUS3_1_2_, bookorders1_.ORDER_TOTAL as ORDER_TOTAL4_1_2_, bookorders1_.PAYMENT_METHOD as PAYMENT_METHOD5_1_2_, bookorders1_.RECIPIENT_NAME as RECIPIENT_NAME6_1_2_, bookorders1_.RECIPIENT_PHONE as RECIPIENT_PHONE7_1_2_, bookorders1_.SHIPPING_ADDRESS as SHIPPING_ADDRESS8_1_2_ from DETAILORDER detailorde0_ inner join BOOKORDERS bookorders1_ on detailorde0_.ORDER_ID=bookorders1_.ORDER_ID where detailorde0_.BOOK_ID=? Hibernate: select orderdetai0_.ORDER_ID as ORDER_ID4_5_0_, orderdetai0_.BOOK_ID as BOOK_ID3_5_0_, orderdetai0_.BOOK_ID as BOOK_ID3_5_1_, orderdetai0_.ORDER_ID as ORDER_ID4_5_1_, orderdetai0_.QUANTITY as QUANTITY1_5_1_, orderdetai0_.SUBTOTAL as SUBTOTAL2_5_1_, book1_.BOOK_ID as BOOK_ID1_0_2_, book1_.AUTHOR as AUTHOR2_0_2_, book1_.CATEGORY_ID as CATEGORY_ID11_0_2_, book1_.DESCRIPTION as DESCRIPTION3_0_2_, book1_.IMAGE as IMAGE4_0_2_, book1_.ISBN as ISBN5_0_2_, book1_.LAST_UPDATED_DATE as LAST_UPDATED_DATE6_0_2_, book1_.PRICE as PRICE7_0_2_, book1_.PUBLISH_DATE as PUBLISH_DATE8_0_2_, book1_.QUANTITY as QUANTITY9_0_2_, book1_.TITLE as TITLE10_0_2_ from DETAILORDER orderdetai0_ inner join BOOK book1_ on orderdetai0_.BOOK_ID=book1_.BOOK_ID where orderdetai0_.ORDER_ID=? Hibernate: select detailorde0_.BOOK_ID as BOOK_ID3_5_0_, detailorde0_.ORDER_ID as ORDER_ID4_5_0_, detailorde0_.BOOK_ID as BOOK_ID3_5_1_, detailorde0_.ORDER_ID as ORDER_ID4_5_1_, detailorde0_.QUANTITY as QUANTITY1_5_1_, detailorde0_.SUBTOTAL as SUBTOTAL2_5_1_, bookorders1_.ORDER_ID as ORDER_ID1_1_2_, bookorders1_.CUSTOMER_ID as CUSTOMER_ID9_1_2_, bookorders1_.ORDER_DATE as ORDER_DATE2_1_2_, bookorders1_.ORDER_STATUS as ORDER_STATUS3_1_2_, bookorders1_.ORDER_TOTAL as ORDER_TOTAL4_1_2_, bookorders1_.PAYMENT_METHOD as PAYMENT_METHOD5_1_2_, bookorders1_.RECIPIENT_NAME as RECIPIENT_NAME6_1_2_, bookorders1_.RECIPIENT_PHONE as RECIPIENT_PHONE7_1_2_, bookorders1_.SHIPPING_ADDRESS as SHIPPING_ADDRESS8_1_2_ from DETAILORDER detailorde0_ inner join BOOKORDERS bookorders1_ on detailorde0_.ORDER_ID=bookorders1_.ORDER_ID where detailorde0_.BOOK_ID=? Hibernate: select detailorde_.BOOK_ID, detailorde_.ORDER_ID, detailorde_.QUANTITY as QUANTITY1_5_, detailorde_.SUBTOTAL as SUBTOTAL2_5_ from DETAILORDER detailorde_ where detailorde_.BOOK_ID=? and detailorde_.ORDER_ID=? Hibernate: select detailorde_.BOOK_ID, detailorde_.ORDER_ID, detailorde_.QUANTITY as QUANTITY1_5_, detailorde_.SUBTOTAL as SUBTOTAL2_5_ from DETAILORDER detailorde_ where detailorde_.BOOK_ID=? and detailorde_.ORDER_ID=? Hibernate: select detailorde_.BOOK_ID, detailorde_.ORDER_ID, detailorde_.QUANTITY as QUANTITY1_5_, detailorde_.SUBTOTAL as SUBTOTAL2_5_ from DETAILORDER detailorde_ where detailorde_.BOOK_ID=? and detailorde_.ORDER_ID=? Hibernate: delete from DETAILORDER where BOOK_ID=? and ORDER_ID=? Hibernate: delete from DETAILORDER where BOOK_ID=? and ORDER_ID=? Hibernate: delete from DETAILORDER where BOOK_ID=? and ORDER_ID=? Hibernate: delete from BOOK where BOOK_ID=? Hibernate: delete from BOOKORDERS where ORDER_ID=? Hibernate: delete from BOOK where BOOK_ID=? May 23, 2019 9:11:57 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 2292, SQLState: 23000 May 23, 2019 9:11:57 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: ORA-02292: integrity constraint (JSPPROJECTDATABASE.FK_BOOK_ID_BOOK_TABLE) violated - child record found 是在“审阅部分”中定义的,但与“审阅”和“预定”没有关系。

我可以创建订单,根据订单ID更新订单,以订单ID为准获取订单,删除过程除外。

我该如何解决?

这是我的数据库模型。

https://ibb.co/ykv8b2X

这是我在评论部分中提到的F​​K。

https://ibb.co/56S4Wg6

这是我的删除代码段

FK_BOOK_ID_BOOK_TABLE

这里是我的EntitY Classs链接。

https://drive.google.com/open?id=1_VYw2j9VMQrA-jnWdGr4lfw5GTQPbY6p

0 个答案:

没有答案