开发者

Hibernate insertion issue

I have two entities:PS_PUBLICATION and PS_PUBLICATION_PROPERTIES

PS_PUBLICATION has a list of PS_PUBLICATION_PROPERTIES

In the logs the inserts look fine but at the end i got an error

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.ConstraintViolationExc开发者_开发技巧eption: Could not execute JDBC batch update   
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:94)

In the inserts everythign look fine !

Any idea what might cause this ?

Thank you !


org.hibernate.exception.ConstraintViolationException:

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

Double check if the data you want to insert does not violate database constraints. It looks like the database isn't happy with the values.

(If you catch that exception, call ex.getConstraintName(), that should give more details.)

Didn't notice, the the constraint name was in the question ;) You'll find that constraint's definition in the database. Ask your oracle instance and it will tell you, which table and thus which insert causes trouble.


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.

You provide two UUIDs as foreign keys - one of them is not a primary key in some other table. Or at least - not recognized as a primary key by oracle.

This link may help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜