2011-07-06 185 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设置 - 啊,发现它,没有滚动窗口;) –