Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • 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: 3913
9
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic