This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Groovy and the fly likes MySQLIntegrityConstraintException -Cannot add or update a child row: a foreign key constraint fails Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Languages » Groovy
Reply Bookmark "MySQLIntegrityConstraintException -Cannot add or update a child row: a foreign key constraint fails" Watch "MySQLIntegrityConstraintException -Cannot add or update a child row: a foreign key constraint fails" New topic
Author

MySQLIntegrityConstraintException -Cannot add or update a child row: a foreign key constraint fails

Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 133

Hi,
Am trying to get some order information from xml file and trying to store it in database(mysql) table. I can retrieve the order information from xml file but when am trying to insert into the table it shows error as MySQLIntegrityConstraintException.

My Grails program shown as below,


When i run the program i get an error as,


Can anyone help me to come out from this problem. Thanks in advance
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

Your order_item table requires an order_item_hdr value which is a FK to order's ID.
Sabarish Venkat
Ranch Hand

Joined: Jan 18, 2012
Posts: 133

Thanks gregg i had looked it and got solved.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: MySQLIntegrityConstraintException -Cannot add or update a child row: a foreign key constraint fails
 
Similar Threads
Simple But Crazy Cascade Problem
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException
Cannot add or update a child row: a foreign key constraint fails
CMR & DB Foreign Key references
hibernat creating the tables without cascade