Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rohit Bhal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rohit Bhal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic