2011-07-06 183 views
0

我有兩個實體:PS_PUBLICATION和PS_PUBLICATION_PROPERTIES休眠插入問題

PS_PUBLICATION有PS_PUBLICATION_PROPERTIES

在日誌中插入看起來不錯清單,但最後我得到一個錯誤

insert into PS_PUBLICATION (CREATION_DATE, message, FK_SUBJECTAREA_ID, status, subject, UPDATE_DATE, id) values (?, ?, ?, ?, ?, ?, ?) 

binding '2011-07-06 10:36:43' to parameter: 1 

binding 'dc8ca7f0-9d8d-11e0-89b1-00212834363a' to parameter: 3 

binding 'PUBLISHED' to parameter: 4 

binding 'publication 2' to parameter: 5 

binding '2011-07-06 10:36:43' to parameter: 6 

binding '13d6df10-a7ab-11e0-ac48-00212834ce10' to parameter: 7 

insert into PS_PUBLICATION_PROPERTIES (PROP_VALUE, PROP_KEY, FK_PUBLICATION_ID) values (?, ?, ?) 

binding 'close' to parameter: 1 

binding 'CALL-CATEGORY-OPEN' to parameter: 2 

binding '13d6df10-a7ab-11e0-ac48-00212834ce10' to parameter: 3 

06 Jul 2011 10:36:43,680 WARN org.hibernate.util.JDBCExceptionReporter:100 - SQL Error: 2291, SQLState: 23000 
06 Jul 2011 10:36:43,681 ERROR org.hibernate.util.JDBCExceptionReporter:101 - ORA-02291: integrity constraint (EPF7_NOTIF.SYS_C0018903) violated - parent key not found 

WARN org.hibernate.util.JDBCExceptionReporter:100 
    - SQL Error: 2291, SQLState: 23000 06 Jul 2011 10:36:43,690 ERROR org.hibernate.event.def.AbstractFlushingEventListener:324 
    - Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update 
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94) 

在插入everythign看起來很好!

任何想法可能會導致這種情況?

謝謝!

回答

3

org.hibernate.exception.ConstraintViolationException

Implementation of JDBCException indicating that the requested DML operation resulted in a violation of a defined integrity constraint.

仔細檢查,如果你想插入不違反數據庫約束的數據。看起來數據庫對這些值不滿意。

(如果你捕獲了異常,請撥打ex.getConstraintName(),應該讓更多的細節。)

沒有注意到,在約束名是問題;)你會發現,約束的定義數據庫。詢問你的oracle實例,它會告訴你,哪個表以及哪個插入引起了麻煩。


Error: ORA-02291: integrity constraint violated - parent key not found

Cause: You tried to reference a table using a unique or primary key, but the columns that you listed did not match the primary key, or a primary key does not exist for this table.

您提供兩個UUID的外鍵 - 其中一人是不是在一些其他表的主鍵。或者至少 - 不被oracle認定爲主鍵。

This link may help

+0

約束名是錯誤消息:EPF7_NOTIF.SYS_C0018903 –

+0

有堆棧中的完整性約束(EPF7_NOTIF.SYS_C0018903)違反 - 父鍵未找到,但如果你在插入:( – Cris

+0

@JB Nizet看everythign設置 - 啊,發現它,沒有滾動窗口;) –