• Post Reply Bookmark Topic Watch Topic
  • New Topic

ORA-02291: integrity constraint, can not find parent key

 
Kamil Kuchta
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kamil Kuchta
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3954
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
G. Prasad,
Your post was moved to a new topic.
 
Rachna Jotwani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the same error. is there any updtae on how to fix this error?
 
Telemart Network
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try another theme or go for latest version. Your key might not be working in this & will execute in next one.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!