Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with MySql 5 FKs  RSS feed

Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys

I have been having some trouble with MySql since it's upgrade and support of Foreign Keys. I have set up my Foreign Key in the tables

id (PK, Auto)

id (PK, Auto)
user_id (FK)

tbl_user_secure Foreign Keys has a reference setup linking it to

My Dao has the following:
@Table(name = "tbl_user_secure")
@SecondaryTable(name = "tbl_user_details", pkJoinColumns = @PrimaryKeyJoinColumn(name = "user_id"))

But when I try to create a new user I get the following:

Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:
Cannot add or update a child row: a foreign key constraint fails
(`users`.`tbl_user_secure`, CONSTRAINT `tbl_user_secure` FOREIGN KEY (`user_id`) REFERENCES `tbl_user_details` (`id`))

Any advice?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!