| Author |
ORA-02291: integrity constraint, can not find parent key
|
Kamil Kuchta
Greenhorn
Joined: Mar 09, 2009
Posts: 17
|
|
I don't know why, Hibernate can not find the primary key of the City which was inserted in the same session with Person. I'm using Oracle 10g.
Hibernate: select diagno.hibernate_sequence.nextval from dual
Hibernate: select diagno.hibernate_sequence.nextval from dual
Hibernate: insert into diagno.City (name, id) values (?, ?)
Hibernate: insert into diagno.Person (name, surname, city_id, id) values (?, ?, ?, ?)
Exception in thread "main" org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
.
.
Caused by: java.sql.BatchUpdateException: ORA-02291: integrity constraint (DIAGNO.PERSON_CITY_FK) violated - parent key not found
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
|
It appears as simple as the error. You have a constraint that says an entry can't go in unless it's associated through it's primary key with another table. Seems like you must have something null going in as the reference key.
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
Kamil Kuchta
Greenhorn
Joined: Mar 09, 2009
Posts: 17
|
|
Unfortunatly, there is no null...
If I get already existing city object, it works fine:
but when the city object is going to be created w person in the same session it doesn't work
|
 |
Pablo Marmol
Greenhorn
Joined: Aug 23, 2010
Posts: 13
|
|
I have this, i think it is the same thing:
http://www.coderanch.com/t/533735/ORM/java/two-parents-one-child-ora
What app server are using? JPA version?
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3673
|
|
G. Prasad, Your post was moved to a new topic.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
Rachna Jotwani
Greenhorn
Joined: Apr 17, 2012
Posts: 2
|
|
|
I am getting the same error. is there any updtae on how to fix this error?
|
 |
Telemart Network
Greenhorn
Joined: Apr 24, 2012
Posts: 4
|
|
|
Try another theme or go for latest version. Your key might not be working in this & will execute in next one.
|
Career Guidance Package English for Beginners
|
 |
 |
|
|
subject: ORA-02291: integrity constraint, can not find parent key
|
|
|