wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails" Watch "java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails" New topic
Author

java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails

Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
Hi

Could someone help me understand that why am I getting the following error when I am trying to persist ServiceProvider entity?


The situation is like this: a ServiceProvider has a List of BusinessLocation and a State has a list of BusinessLocation.

Following annotated classes that I want to be persisted:
ServiceProvider.java


BusinessLocation,java



Looking forward to someone waking me up of the blunder I might be commiting here.
Thanks.


Skip Skipping
Rohit Bhal
Ranch Hand

Joined: Aug 28, 2007
Posts: 44
Hi
I've got this problem resolved. The blunder that I was committting was that I was trying to override the automatically generated IDs by Hibernate.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
 
Similar Threads
Bidirectional @OneToOne with JoinTable
Hibernate: not getting the associated List retrieved
AbstractWizardFormController: teasing command object
Hibernate @GeneratedValue problem
AbstractWizardFormController: java.lang.NullPointerException at processFinish(...)