How to insert records in one to one relationship?
lets say i have 3 tables : table A , table B, table C
I have to insert a record into those tables which table A is referenced as the main table for primary key.
Lets just say like this:
tableB.PK = tableA.PK
tableC.PK = tableA.PK
Now,
when I am inserting records in tableB or tableC the error occurs:
Error Message: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tableB_tableA"
But when I am inserting in tableA which is the basis of the two tables' primary keys, it is ok and it increments.
How would I insert a record? Specifically in JPA.
- Do I need to insert into tableA first then insert in others? (Just did that and it does not work)
- Do I need to insert data in the tables at the same time? (How? in JPA will be good)