Forums Register Login

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

+Pie Number of slices to send: Send




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

 
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
I have this, i think it is the same thing:

https://coderanch.com/t/533735/ORM/java/two-parents-one-child-ora

What app server are using? JPA version?
+Pie Number of slices to send: Send
G. Prasad,
Your post was moved to a new topic.
+Pie Number of slices to send: Send
I am getting the same error. is there any updtae on how to fix this error?
+Pie Number of slices to send: Send
Try another theme or go for latest version. Your key might not be working in this & will execute in next one.
Evildoers! Eat my justice! And this tiny ad's justice too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 18887 times.
Similar Threads
org.hibernate.MappingException: Could not determine type for:... with @ManyToOne
EJB3/JPA @OneToOne
Persistance issue
non-standard join in ManyToOne
one to one unidirectional mapping in jpa
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:25:48.